use of com.google.inject.Module in project hadoop by apache.
the class TestNodesPage method setUp.
@Before
public void setUp() throws Exception {
final RMContext mockRMContext = TestRMWebApp.mockRMContext(3, numberOfRacks, numberOfNodesPerRack, 8 * TestRMWebApp.GiB);
injector = WebAppTests.createMockInjector(RMContext.class, mockRMContext, new Module() {
@Override
public void configure(Binder binder) {
try {
binder.bind(ResourceManager.class).toInstance(TestRMWebApp.mockRm(mockRMContext));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
});
}
use of com.google.inject.Module in project druid by druid-io.
the class TimestampMinMaxAggregatorTest method setup.
@Before
public void setup() throws Exception {
injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(new Module() {
@Override
public void configure(Binder binder) {
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("test");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
}
}, new TimestampMinMaxModule()));
mapper = injector.getInstance(ObjectMapper.class);
String json = "{\"type\":\"" + aggType + "\",\"name\":\"" + aggType + "\",\"fieldName\":\"test\"}";
aggregatorFactory = mapper.readValue(json, aggClass);
selector = new TestObjectColumnSelector(values);
selectorFactory = EasyMock.createMock(ColumnSelectorFactory.class);
EasyMock.expect(selectorFactory.makeObjectColumnSelector("test")).andReturn(selector);
EasyMock.replay(selectorFactory);
}
use of com.google.inject.Module in project druid by druid-io.
the class OrcHadoopInputRowParserTest method setUp.
@Before
public void setUp() {
injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(new Module() {
@Override
public void configure(Binder binder) {
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("test");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
}
}, new OrcExtensionsModule()));
mapper = injector.getInstance(ObjectMapper.class);
}
use of com.google.inject.Module in project druid by druid-io.
the class CacheMonitorTest method testOptionalInject.
@Test
public void testOptionalInject() throws Exception {
Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.of(new Module() {
@Override
public void configure(Binder binder) {
JsonConfigProvider.bindInstance(binder, Key.get(DruidNode.class, Self.class), new DruidNode("test-inject", null, null));
}
}));
CacheMonitor monitor = injector.getInstance(CacheMonitor.class);
Assert.assertNull(monitor.cache);
}
use of com.google.inject.Module in project druid by druid-io.
the class MockMemcachedClient method testSimpleInjection.
@Test
public void testSimpleInjection() {
final String uuid = UUID.randomUUID().toString();
System.setProperty(uuid + ".type", "memcached");
System.setProperty(uuid + ".hosts", "localhost");
final Injector injector = Initialization.makeInjectorWithModules(GuiceInjectors.makeStartupInjector(), ImmutableList.<Module>of(new Module() {
@Override
public void configure(Binder binder) {
binder.bindConstant().annotatedWith(Names.named("serviceName")).to("druid/test/memcached");
binder.bindConstant().annotatedWith(Names.named("servicePort")).to(0);
binder.bind(Cache.class).toProvider(CacheProvider.class);
JsonConfigProvider.bind(binder, uuid, CacheProvider.class);
}
}));
final CacheProvider memcachedCacheProvider = injector.getInstance(CacheProvider.class);
Assert.assertNotNull(memcachedCacheProvider);
Assert.assertEquals(MemcachedCacheProvider.class, memcachedCacheProvider.getClass());
}
Aggregations