Search in sources :

Example 1 with DruidGuiceExtensions

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

the class ComposingEmitterModuleTest method testGetEmitterViaRealGuice.

@Test
public void testGetEmitterViaRealGuice() {
    Injector injector = Guice.createInjector(new DruidGuiceExtensions(), new LifecycleModule(), new Module() {

        @Override
        public void configure(Binder binder) {
            Properties props = new Properties();
            props.put("druid.emitter.composing.emitters", "[\"" + testEmitterType + "\"]");
            binder.bind(Properties.class).toInstance(props);
            binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
            binder.bind(Emitter.class).annotatedWith(Names.named(testEmitterType)).toInstance(emitter);
        }
    }, new ComposingEmitterModule());
    injector.getInstance(Key.get(Emitter.class, Names.named("composing"))).start();
    EasyMock.verify(emitter);
}
Also used : Binder(com.google.inject.Binder) Emitter(com.metamx.emitter.core.Emitter) DruidGuiceExtensions(io.druid.guice.DruidGuiceExtensions) Injector(com.google.inject.Injector) Module(com.google.inject.Module) LifecycleModule(io.druid.guice.LifecycleModule) ComposingEmitterModule(io.druid.server.initialization.ComposingEmitterModule) Properties(java.util.Properties) ComposingEmitterModule(io.druid.server.initialization.ComposingEmitterModule) LifecycleModule(io.druid.guice.LifecycleModule) Test(org.junit.Test)

Example 2 with DruidGuiceExtensions

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

the class AuthenticationKerberosConfigTest method testserde.

@Test
public void testserde() {
    Injector injector = Guice.createInjector(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.install(new PropertiesModule(Arrays.asList("test.runtime.properties")));
            binder.install(new ConfigModule());
            binder.install(new DruidGuiceExtensions());
            JsonConfigProvider.bind(binder, "druid.hadoop.security.kerberos", AuthenticationKerberosConfig.class);
        }

        @Provides
        @LazySingleton
        public ObjectMapper jsonMapper() {
            return new DefaultObjectMapper();
        }
    });
    Properties props = injector.getInstance(Properties.class);
    AuthenticationKerberosConfig config = injector.getInstance(AuthenticationKerberosConfig.class);
    Assert.assertEquals(props.getProperty("druid.hadoop.security.kerberos.principal"), config.getPrincipal());
    Assert.assertEquals(props.getProperty("druid.hadoop.security.kerberos.keytab"), config.getKeytab());
}
Also used : DruidGuiceExtensions(io.druid.guice.DruidGuiceExtensions) ConfigModule(io.druid.guice.ConfigModule) Provides(com.google.inject.Provides) Properties(java.util.Properties) Binder(com.google.inject.Binder) LazySingleton(io.druid.guice.LazySingleton) Injector(com.google.inject.Injector) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Module(com.google.inject.Module) PropertiesModule(io.druid.guice.PropertiesModule) ConfigModule(io.druid.guice.ConfigModule) PropertiesModule(io.druid.guice.PropertiesModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Test(org.junit.Test)

Example 3 with DruidGuiceExtensions

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

the class SpnegoFilterConfigTest method testserde.

@Test
public void testserde() {
    Injector injector = Guice.createInjector(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.install(new PropertiesModule(Arrays.asList("test.runtime.properties")));
            binder.install(new ConfigModule());
            binder.install(new DruidGuiceExtensions());
            JsonConfigProvider.bind(binder, "druid.hadoop.security.spnego", SpnegoFilterConfig.class);
        }

        @Provides
        @LazySingleton
        public ObjectMapper jsonMapper() {
            return new DefaultObjectMapper();
        }
    });
    Properties props = injector.getInstance(Properties.class);
    SpnegoFilterConfig config = injector.getInstance(SpnegoFilterConfig.class);
    Assert.assertEquals(props.getProperty("druid.hadoop.security.spnego.principal"), config.getPrincipal());
    Assert.assertEquals(props.getProperty("druid.hadoop.security.spnego.keytab"), config.getKeytab());
    Assert.assertEquals(props.getProperty("druid.hadoop.security.spnego.authToLocal"), config.getAuthToLocal());
}
Also used : DruidGuiceExtensions(io.druid.guice.DruidGuiceExtensions) ConfigModule(io.druid.guice.ConfigModule) Provides(com.google.inject.Provides) Properties(java.util.Properties) Binder(com.google.inject.Binder) LazySingleton(io.druid.guice.LazySingleton) Injector(com.google.inject.Injector) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Module(com.google.inject.Module) PropertiesModule(io.druid.guice.PropertiesModule) ConfigModule(io.druid.guice.ConfigModule) PropertiesModule(io.druid.guice.PropertiesModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Test(org.junit.Test)

Aggregations

Binder (com.google.inject.Binder)3 Injector (com.google.inject.Injector)3 Module (com.google.inject.Module)3 DruidGuiceExtensions (io.druid.guice.DruidGuiceExtensions)3 Properties (java.util.Properties)3 Test (org.junit.Test)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Provides (com.google.inject.Provides)2 ConfigModule (io.druid.guice.ConfigModule)2 LazySingleton (io.druid.guice.LazySingleton)2 PropertiesModule (io.druid.guice.PropertiesModule)2 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)2 Emitter (com.metamx.emitter.core.Emitter)1 LifecycleModule (io.druid.guice.LifecycleModule)1 ComposingEmitterModule (io.druid.server.initialization.ComposingEmitterModule)1