use of org.apache.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.
the class NamespaceLookupExtractorFactoryTest method testStartFailsToSchedule.
@Test
public void testStartFailsToSchedule() throws Exception {
final ExtractionNamespace extractionNamespace = new ExtractionNamespace() {
@Override
public long getPollMs() {
return 0;
}
};
try {
when(scheduler.scheduleAndWait(extractionNamespace, 60000L)).thenReturn(null);
} catch (InterruptedException e) {
throw new AssertionError(e);
}
final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
Assert.assertFalse(namespaceLookupExtractorFactory.start());
// true because it never fully started
Assert.assertTrue(namespaceLookupExtractorFactory.close());
verify(scheduler).scheduleAndWait(extractionNamespace, 60000L);
verifyNoMoreInteractions(scheduler, entry, versionedCache);
}
use of org.apache.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 = () -> 0;
when(scheduler.scheduleAndWait(extractionNamespace, 1L)).thenReturn(null);
final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, 1, false, scheduler);
Assert.assertFalse(namespaceLookupExtractorFactory.start());
verify(scheduler).scheduleAndWait(extractionNamespace, 1L);
verifyNoMoreInteractions(scheduler, entry, versionedCache);
}
use of org.apache.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.
the class NamespaceLookupExtractorFactoryTest method testSimpleStartGetStop.
@Test
public void testSimpleStartGetStop() throws Exception {
final ExtractionNamespace extractionNamespace = () -> 0;
expectScheduleAndWaitOnce(extractionNamespace);
when(entry.getCacheState()).thenReturn(versionedCache);
when(entry.getCache()).thenReturn(new HashMap<String, String>());
when(versionedCache.getCache()).thenReturn(new HashMap<>());
when(versionedCache.getVersion()).thenReturn("0");
final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
Assert.assertTrue(namespaceLookupExtractorFactory.start());
final LookupExtractor extractor = namespaceLookupExtractorFactory.get();
Assert.assertNull(extractor.apply("foo"));
Assert.assertTrue(namespaceLookupExtractorFactory.close());
verify(scheduler).scheduleAndWait(extractionNamespace, 60000L);
verify(entry).getCacheState();
verify(entry).close();
verify(versionedCache).getVersion();
verify(versionedCache, atLeastOnce()).getCache();
verifyNoMoreInteractions(scheduler, entry, versionedCache);
}
Aggregations