Search in sources :

Example 11 with JsonConfigurator

use of io.druid.guice.JsonConfigurator in project druid by druid-io.

the class LookupListeningAnnouncerConfigTest method testDefaultInjection.

@Test
public void testDefaultInjection() {
    final JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
    final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(propertyBase, LookupListeningAnnouncerConfig.class);
    configProvider.inject(properties, configurator);
    final LookupListeningAnnouncerConfig config = configProvider.get().get();
    Assert.assertEquals(LookupListeningAnnouncerConfig.DEFAULT_TIER, config.getLookupTier());
}
Also used : JsonConfigurator(io.druid.guice.JsonConfigurator) Test(org.junit.Test)

Example 12 with JsonConfigurator

use of io.druid.guice.JsonConfigurator in project druid by druid-io.

the class LookupListeningAnnouncerConfigTest method testFailsOnEmptyTier.

@Test(expected = NullPointerException.class)
public void testFailsOnEmptyTier() {
    final JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
    properties.put(propertyBase + ".lookupTier", "");
    final JsonConfigProvider<LookupListeningAnnouncerConfig> configProvider = JsonConfigProvider.of(propertyBase, LookupListeningAnnouncerConfig.class);
    configProvider.inject(properties, configurator);
    final LookupListeningAnnouncerConfig config = configProvider.get().get();
    config.getLookupTier();
}
Also used : JsonConfigurator(io.druid.guice.JsonConfigurator) Test(org.junit.Test)

Example 13 with JsonConfigurator

use of io.druid.guice.JsonConfigurator in project druid by druid-io.

the class IndexerZkConfigTest method testIndexerBaseOverride.

@Test
public void testIndexerBaseOverride() {
    final String overrideValue = "/foo/bar/baz";
    final String indexerPropertyKey = indexerPropertyString + ".base";
    final String priorValue = System.getProperty(indexerPropertyKey);
    // Set it here so that the binding picks it up
    System.setProperty(indexerPropertyKey, overrideValue);
    final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.<Module>of(simpleZkConfigModule));
    propertyValues.clear();
    // Have to set it here as well annoyingly enough
    propertyValues.setProperty(indexerPropertyKey, overrideValue);
    JsonConfigurator configurator = injector.getBinding(JsonConfigurator.class).getProvider().get();
    JsonConfigProvider<IndexerZkConfig> indexerPathsConfig = JsonConfigProvider.of(indexerPropertyString, IndexerZkConfig.class);
    indexerPathsConfig.inject(propertyValues, configurator);
    IndexerZkConfig indexerZkConfig = indexerPathsConfig.get().get();
    // Rewind value before we potentially fail
    if (priorValue == null) {
        System.clearProperty(indexerPropertyKey);
    } else {
        System.setProperty(indexerPropertyKey, priorValue);
    }
    Assert.assertEquals(overrideValue, indexerZkConfig.getBase());
    Assert.assertEquals(overrideValue + "/announcements", indexerZkConfig.getAnnouncementsPath());
}
Also used : Injector(com.google.inject.Injector) JsonConfigurator(io.druid.guice.JsonConfigurator) Test(org.junit.Test)

Aggregations

JsonConfigurator (io.druid.guice.JsonConfigurator)13 Test (org.junit.Test)13 Injector (com.google.inject.Injector)7 ImmutableList (com.google.common.collect.ImmutableList)3 Lists (com.google.common.collect.Lists)3 Ints (com.google.common.primitives.Ints)3 Inject (com.google.inject.Inject)3 Module (com.google.inject.Module)3 Names (com.google.inject.name.Names)3 GuiceInjectors (io.druid.guice.GuiceInjectors)3 JsonConfigProvider (io.druid.guice.JsonConfigProvider)3 ManageLifecycle (io.druid.guice.ManageLifecycle)3 Initialization (io.druid.initialization.Initialization)3 Lifecycle (io.druid.java.util.common.lifecycle.Lifecycle)3 Field (java.lang.reflect.Field)3 Method (java.lang.reflect.Method)3 Map (java.util.Map)3 Properties (java.util.Properties)3 Random (java.util.Random)3 UUID (java.util.UUID)3