Search in sources :

Example 1 with ComposingEmitterModule

use of org.apache.druid.server.emitter.ComposingEmitterModule 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(org.apache.druid.java.util.emitter.core.Emitter) DruidGuiceExtensions(org.apache.druid.guice.DruidGuiceExtensions) Injector(com.google.inject.Injector) Module(com.google.inject.Module) LifecycleModule(org.apache.druid.guice.LifecycleModule) ComposingEmitterModule(org.apache.druid.server.emitter.ComposingEmitterModule) Properties(java.util.Properties) ComposingEmitterModule(org.apache.druid.server.emitter.ComposingEmitterModule) LifecycleModule(org.apache.druid.guice.LifecycleModule) Test(org.junit.Test)

Example 2 with ComposingEmitterModule

use of org.apache.druid.server.emitter.ComposingEmitterModule in project druid by druid-io.

the class ComposingEmitterModuleTest method testGetEmitter.

@Test
public void testGetEmitter() {
    ComposingEmitterConfig config = EasyMock.createMock(ComposingEmitterConfig.class);
    EasyMock.expect(config.getEmitters()).andReturn(Collections.singletonList(testEmitterType)).anyTimes();
    Injector injector = EasyMock.createMock(Injector.class);
    EasyMock.expect(injector.getInstance(Key.get(Emitter.class, Names.named(testEmitterType)))).andReturn(emitter);
    EasyMock.replay(config, injector);
    Emitter composingEmitter = new ComposingEmitterModule().getEmitter(config, injector);
    composingEmitter.start();
    EasyMock.verify(config, emitter, injector);
}
Also used : Emitter(org.apache.druid.java.util.emitter.core.Emitter) Injector(com.google.inject.Injector) ComposingEmitterConfig(org.apache.druid.server.emitter.ComposingEmitterConfig) ComposingEmitterModule(org.apache.druid.server.emitter.ComposingEmitterModule) Test(org.junit.Test)

Aggregations

Injector (com.google.inject.Injector)2 Emitter (org.apache.druid.java.util.emitter.core.Emitter)2 ComposingEmitterModule (org.apache.druid.server.emitter.ComposingEmitterModule)2 Test (org.junit.Test)2 Binder (com.google.inject.Binder)1 Module (com.google.inject.Module)1 Properties (java.util.Properties)1 DruidGuiceExtensions (org.apache.druid.guice.DruidGuiceExtensions)1 LifecycleModule (org.apache.druid.guice.LifecycleModule)1 ComposingEmitterConfig (org.apache.druid.server.emitter.ComposingEmitterConfig)1