use of io.druid.guice.JsonConfigurator in project druid by druid-io.
the class LookupListeningAnnouncerConfigTest method testSimpleInjection.
@Test
public void testSimpleInjection() {
final String lookupTier = "some_tier";
final JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
properties.put(propertyBase + ".lookupTier", lookupTier);
final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(propertyBase, LookupListeningAnnouncerConfig.class);
configProvider.inject(properties, configurator);
final LookupListeningAnnouncerConfig config = configProvider.get().get();
Assert.assertEquals(lookupTier, config.getLookupTier());
}
use of io.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(propertyBase + ".lookupTier", lookupTier);
properties.put(propertyBase + ".lookupTierIsDatasource", "true");
final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(propertyBase, LookupListeningAnnouncerConfig.class);
configProvider.inject(properties, configurator);
final LookupListeningAnnouncerConfig config = configProvider.get().get();
Assert.assertEquals(lookupTier, config.getLookupTier());
}
use of io.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(propertyBase + ".lookupTierIsDatasource", "true");
final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(propertyBase, LookupListeningAnnouncerConfig.class);
configProvider.inject(properties, configurator);
final LookupListeningAnnouncerConfig config = configProvider.get().get();
Assert.assertEquals("some_datasource", config.getLookupTier());
}
use of io.druid.guice.JsonConfigurator in project druid by druid-io.
the class CaffeineCacheProviderWithConfig method testMixedCaseFromProperties.
@Test
public void testMixedCaseFromProperties() {
final String keyPrefix = "cache.config.prefix";
final Properties properties = new Properties();
properties.put(keyPrefix + ".expireAfter", "10");
properties.put(keyPrefix + ".sizeInBytes", "100");
properties.put(keyPrefix + ".cacheExecutorFactory", "CoMmON_FjP");
final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.<Module>of(binder -> {
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/test");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
JsonConfigProvider.bind(binder, keyPrefix, CaffeineCacheConfig.class);
}));
final JsonConfigurator configurator = injector.getInstance(JsonConfigurator.class);
final JsonConfigProvider<CaffeineCacheConfig> caffeineCacheConfigJsonConfigProvider = JsonConfigProvider.of(keyPrefix, CaffeineCacheConfig.class);
caffeineCacheConfigJsonConfigProvider.inject(properties, configurator);
final CaffeineCacheConfig config = caffeineCacheConfigJsonConfigProvider.get().get();
Assert.assertEquals(10, config.getExpireAfter());
Assert.assertEquals(100, config.getSizeInBytes());
Assert.assertEquals(ForkJoinPool.commonPool(), config.createExecutor());
}
use of io.druid.guice.JsonConfigurator in project druid by druid-io.
the class ZkPathsConfigTest method testOverrideBaseOnlyConfig.
@Test
public void testOverrideBaseOnlyConfig() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException, IOException {
JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
JsonConfigProvider<ZkPathsConfig> zkPathsConfig = JsonConfigProvider.of(configPrefix, ZkPathsConfig.class);
testProperties.clear();
String base = UUID.randomUUID().toString();
testProperties.put(String.format("%s.base", configPrefix), base);
zkPathsConfig.inject(testProperties, configurator);
propertyValues.clear();
propertyValues.put(String.format("%s.base", configPrefix), base);
propertyValues.put(String.format("%s.propertiesPath", configPrefix), ZKPaths.makePath(base, "properties"));
propertyValues.put(String.format("%s.announcementsPath", configPrefix), ZKPaths.makePath(base, "announcements"));
propertyValues.put(String.format("%s.servedSegmentsPath", configPrefix), ZKPaths.makePath(base, "servedSegments"));
propertyValues.put(String.format("%s.liveSegmentsPath", configPrefix), ZKPaths.makePath(base, "segments"));
propertyValues.put(String.format("%s.coordinatorPath", configPrefix), ZKPaths.makePath(base, "coordinator"));
propertyValues.put(String.format("%s.loadQueuePath", configPrefix), ZKPaths.makePath(base, "loadQueue"));
propertyValues.put(String.format("%s.connectorPath", configPrefix), ZKPaths.makePath(base, "connector"));
ZkPathsConfig zkPathsConfigObj = zkPathsConfig.get().get();
validateEntries(zkPathsConfigObj);
Assert.assertEquals(propertyValues.size(), assertions);
ObjectMapper jsonMapper = injector.getProvider(Key.get(ObjectMapper.class, Json.class)).get();
String jsonVersion = jsonMapper.writeValueAsString(zkPathsConfigObj);
ZkPathsConfig zkPathsConfigObjDeSer = jsonMapper.readValue(jsonVersion, ZkPathsConfig.class);
Assert.assertEquals(zkPathsConfigObj, zkPathsConfigObjDeSer);
}
Aggregations