use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.
the class NamespaceLookupExtractorFactoryTest method testStartReturnsImmediately.
@Test
public void testStartReturnsImmediately() {
final ExtractionNamespace extractionNamespace = new ExtractionNamespace() {
@Override
public long getPollMs() {
return 0;
}
};
EasyMock.expect(scheduler.schedule(EasyMock.eq(extractionNamespace))).andReturn(entry).once();
expectEntryCloseOnce();
mockReplay();
final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, 0, false, scheduler);
Assert.assertTrue(namespaceLookupExtractorFactory.start());
Assert.assertTrue(namespaceLookupExtractorFactory.close());
mockVerify();
}
use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.
the class NamespaceLookupExtractorFactoryTest method testSimpleStartStop.
@Test
public void testSimpleStartStop() {
final ExtractionNamespace extractionNamespace = new ExtractionNamespace() {
@Override
public long getPollMs() {
return 0;
}
};
expectScheduleAndWaitOnce(extractionNamespace);
expectEntryCloseOnce();
mockReplay();
final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
Assert.assertTrue(namespaceLookupExtractorFactory.start());
Assert.assertTrue(namespaceLookupExtractorFactory.close());
mockVerify();
}
use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.
the class NamespaceLookupExtractorFactoryTest method testStartReturnsImmediatelyAndFails.
@Test
public void testStartReturnsImmediatelyAndFails() throws InterruptedException {
final ExtractionNamespace extractionNamespace = new ExtractionNamespace() {
@Override
public long getPollMs() {
return 0;
}
};
EasyMock.expect(scheduler.scheduleAndWait(EasyMock.eq(extractionNamespace), EasyMock.eq(1L))).andReturn(null).once();
mockReplay();
final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, 1, false, scheduler);
Assert.assertFalse(namespaceLookupExtractorFactory.start());
mockVerify();
}
use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.
the class NamespaceLookupExtractorFactoryTest method testExceptionalIntrospectionHandler.
@Test
public void testExceptionalIntrospectionHandler() throws Exception {
final ExtractionNamespace extractionNamespace = PowerMock.createStrictMock(ExtractionNamespace.class);
EasyMock.expect(scheduler.scheduleAndWait(EasyMock.eq(extractionNamespace), EasyMock.anyLong())).andReturn(entry).once();
mockReplay();
final LookupExtractorFactory lookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
Assert.assertTrue(lookupExtractorFactory.start());
final LookupIntrospectHandler handler = lookupExtractorFactory.getIntrospectHandler();
Assert.assertNotNull(handler);
final Class<? extends LookupIntrospectHandler> clazz = handler.getClass();
mockVerify();
mockReset();
EasyMock.expect(entry.getCacheState()).andReturn(CacheScheduler.NoCache.CACHE_NOT_INITIALIZED).once();
mockReplay();
final Response response = (Response) clazz.getMethod("getVersion").invoke(handler);
Assert.assertEquals(404, response.getStatus());
validateNotFound("getKeys", handler, clazz);
validateNotFound("getValues", handler, clazz);
validateNotFound("getMap", handler, clazz);
mockVerify();
}
use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.
the class NamespaceLookupExtractorFactoryTest method testReplaces.
@Test
public void testReplaces() {
final ExtractionNamespace en1 = PowerMock.createStrictMock(ExtractionNamespace.class), en2 = PowerMock.createStrictMock(ExtractionNamespace.class);
PowerMock.replay(en1, en2);
final NamespaceLookupExtractorFactory f1 = new NamespaceLookupExtractorFactory(en1, scheduler), f2 = new NamespaceLookupExtractorFactory(en2, scheduler), f1b = new NamespaceLookupExtractorFactory(en1, scheduler);
Assert.assertTrue(f1.replaces(f2));
Assert.assertTrue(f2.replaces(f1));
Assert.assertFalse(f1.replaces(f1b));
Assert.assertFalse(f1b.replaces(f1));
Assert.assertFalse(f1.replaces(f1));
Assert.assertTrue(f1.replaces(EasyMock.createNiceMock(LookupExtractorFactory.class)));
PowerMock.verify(en1, en2);
}
Aggregations