use of org.apache.druid.guice.JsonConfigurator in project druid by druid-io.
the class FilteredRequestLoggerTest method testInvalidDelegateType.
@Test
public void testInvalidDelegateType() {
final Properties properties = new Properties();
properties.setProperty("log.type", "filtered");
properties.setProperty("log.queryTimeThresholdMs", "100");
properties.setProperty("log.delegate.type", "nope");
final JsonConfigurator configurator = new JsonConfigurator(mapper, Validation.buildDefaultValidatorFactory().getValidator());
expectedException.expect(ProvisionException.class);
expectedException.expectMessage("Could not resolve type id 'nope'");
configurator.configurate(properties, "log", RequestLoggerProvider.class);
}
use of org.apache.druid.guice.JsonConfigurator in project druid by druid-io.
the class FilteredRequestLoggerTest method testConfiguration.
@Test
public void testConfiguration() {
final Properties properties = new Properties();
properties.setProperty("log.type", "filtered");
properties.setProperty("log.queryTimeThresholdMs", "100");
properties.setProperty("log.delegate.type", "slf4j");
properties.setProperty("log.delegate.setMDC", "true");
properties.setProperty("log.delegate.setContextMDC", "true");
final JsonConfigurator configurator = new JsonConfigurator(mapper, Validation.buildDefaultValidatorFactory().getValidator());
final FilteredRequestLoggerProvider provider = (FilteredRequestLoggerProvider) configurator.configurate(properties, "log", RequestLoggerProvider.class);
final FilteredRequestLoggerProvider.FilteredRequestLogger logger = ((FilteredRequestLoggerProvider.FilteredRequestLogger) provider.get());
final LoggingRequestLogger delegate = (LoggingRequestLogger) logger.getDelegate();
Assert.assertEquals(100, logger.getQueryTimeThresholdMs());
Assert.assertTrue(delegate.isSetContextMDC());
Assert.assertTrue(delegate.isSetMDC());
}
use of org.apache.druid.guice.JsonConfigurator in project druid by druid-io.
the class FilteredRequestLoggerTest method testNoDelegate.
@Test
public void testNoDelegate() {
final Properties properties = new Properties();
properties.setProperty("log.type", "filtered");
properties.setProperty("log.queryTimeThresholdMs", "100");
final JsonConfigurator configurator = new JsonConfigurator(mapper, Validation.buildDefaultValidatorFactory().getValidator());
expectedException.expect(ProvisionException.class);
expectedException.expectMessage("log.delegate - may not be null");
configurator.configurate(properties, "log", RequestLoggerProvider.class);
}
use of org.apache.druid.guice.JsonConfigurator in project druid by druid-io.
the class LookupListeningAnnouncerConfigTest method testDatasourceInjection.
@Test
public void testDatasourceInjection() {
final JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
properties.put(PROPERTY_BASE + ".lookupTierIsDatasource", "true");
final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(PROPERTY_BASE, LookupListeningAnnouncerConfig.class);
configProvider.inject(properties, configurator);
final LookupListeningAnnouncerConfig config = configProvider.get().get();
Assert.assertEquals("some_datasource", config.getLookupTier());
}
use of org.apache.druid.guice.JsonConfigurator in project druid by druid-io.
the class LookupListeningAnnouncerConfigTest method testFailsInjection.
@Test(expected = IllegalArgumentException.class)
public void testFailsInjection() {
final String lookupTier = "some_tier";
final JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
properties.put(PROPERTY_BASE + ".lookupTier", lookupTier);
properties.put(PROPERTY_BASE + ".lookupTierIsDatasource", "true");
final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(PROPERTY_BASE, LookupListeningAnnouncerConfig.class);
configProvider.inject(properties, configurator);
final LookupListeningAnnouncerConfig config = configProvider.get().get();
Assert.assertEquals(lookupTier, config.getLookupTier());
}
Aggregations