use of org.apache.druid.guice.DruidGuiceExtensions in project druid by druid-io.
the class BrokerInternalQueryConfigTest method testDefaultBehavior.
/**
* Test the behavior if the operator does not specify anything for druid.broker.internal.query.config.context in runtime.properties
*/
@Test
public void testDefaultBehavior() {
Injector injector = Guice.createInjector(new Module() {
@Override
public void configure(Binder binder) {
binder.install(new ConfigModule());
binder.install(new DruidGuiceExtensions());
JsonConfigProvider.bind(binder, "druid.broker.internal.query.config", BrokerInternalQueryConfig.class);
}
@Provides
@LazySingleton
public ObjectMapper jsonMapper() {
return new DefaultObjectMapper();
}
});
BrokerInternalQueryConfig config = injector.getInstance(BrokerInternalQueryConfig.class);
Assert.assertEquals(ImmutableMap.of(), config.getContext());
}
use of org.apache.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);
}
use of org.apache.druid.guice.DruidGuiceExtensions in project druid by druid-io.
the class SqlModuleTest method makeInjectorWithProperties.
private Injector makeInjectorWithProperties(final Properties props) {
return Guice.createInjector(ImmutableList.of(new DruidGuiceExtensions(), new LifecycleModule(), new ServerModule(), new JacksonModule(), (Module) binder -> {
binder.bind(Validator.class).toInstance(Validation.buildDefaultValidatorFactory().getValidator());
binder.bind(JsonConfigurator.class).in(LazySingleton.class);
binder.bind(Properties.class).toInstance(props);
binder.bind(ExprMacroTable.class).toInstance(ExprMacroTable.nil());
binder.bind(AuthorizerMapper.class).toInstance(CalciteTests.TEST_AUTHORIZER_MAPPER);
binder.bind(Escalator.class).toInstance(new NoopEscalator());
binder.bind(ServiceEmitter.class).toInstance(serviceEmitter);
binder.bind(RequestLogger.class).toInstance(new NoopRequestLogger());
binder.bind(new TypeLiteral<Supplier<DefaultQueryConfig>>() {
}).toInstance(Suppliers.ofInstance(new DefaultQueryConfig(null)));
binder.bind(FilteredServerInventoryView.class).toInstance(inventoryView);
binder.bind(TimelineServerView.class).toInstance(timelineServerView);
binder.bind(DruidLeaderClient.class).annotatedWith(Coordinator.class).toInstance(druidLeaderClient);
binder.bind(DruidLeaderClient.class).annotatedWith(IndexingService.class).toInstance(druidLeaderClient);
binder.bind(DruidNodeDiscoveryProvider.class).toInstance(druidNodeDiscoveryProvider);
binder.bind(GenericQueryMetricsFactory.class).toInstance(genericQueryMetricsFactory);
binder.bind(QuerySegmentWalker.class).toInstance(querySegmentWalker);
binder.bind(QueryToolChestWarehouse.class).toInstance(queryToolChestWarehouse);
binder.bind(LookupExtractorFactoryContainerProvider.class).toInstance(lookupExtractorFactoryContainerProvider);
binder.bind(JoinableFactory.class).toInstance(joinableFactory);
binder.bind(SegmentLoader.class).toInstance(segmentLoader);
binder.bind(QuerySchedulerProvider.class).in(LazySingleton.class);
binder.bind(QueryScheduler.class).toProvider(QuerySchedulerProvider.class).in(LazySingleton.class);
}, new SqlModule(props), new TestViewManagerModule()));
}
Aggregations