Пример #1
0
  @Before
  public void setUp() throws Exception {
    objectMapper
        .getSubtypeResolver()
        .registerSubtypes(
            ConsoleReporterFactory.class, CsvReporterFactory.class, Slf4jReporterFactory.class);

    this.config = factory.build(new File(Resources.getResource("yaml/metrics.yml").toURI()));
  }
Пример #2
0
  @Test
  public void ensureConfigSerializable() throws Exception {
    final ObjectMapper mapper = Jackson.newObjectMapper();
    mapper
        .getSubtypeResolver()
        .registerSubtypes(ServiceFinder.find(AppenderFactory.class).toClassArray());

    // Issue-96: some types were not serializable
    final String json = mapper.writeValueAsString(configuration);
    assertThat(json).isNotNull();

    // and as an added bonus, let's see we can also read it back:
    final Configuration cfg = mapper.readValue(json, Configuration.class);
    assertThat(cfg).isNotNull();
  }
  @Before
  public void setUp() throws Exception {
    final ObjectMapper objectMapper = Jackson.newObjectMapper();
    objectMapper
        .getSubtypeResolver()
        .registerSubtypes(
            ConsoleAppenderFactory.class,
            FileAppenderFactory.class,
            SyslogAppenderFactory.class,
            HttpConnectorFactory.class);

    this.http =
        new ConfigurationFactory<>(
                DefaultServerFactory.class, BaseValidator.newValidator(), objectMapper, "dw")
            .build(new File(Resources.getResource("yaml/server.yml").toURI()));
  }