use of io.druid.query.lookup.namespace.URIExtractionNamespace in project druid by druid-io.
the class NamespaceExtractionCacheManagerExecutorsTest method testSimpleSubmission.
@Test(timeout = 10_000)
public void testSimpleSubmission() throws ExecutionException, InterruptedException {
URIExtractionNamespace namespace = new URIExtractionNamespace(tmpFile.toURI(), null, null, new URIExtractionNamespace.ObjectMapperFlatDataParser(URIExtractionNamespaceTest.registerTypes(new ObjectMapper())), new Period(0), null);
CacheScheduler.Entry entry = scheduler.schedule(namespace);
waitFor(entry);
Map<String, String> cache = entry.getCache();
Assert.assertNull(cache.put("key", "val"));
Assert.assertEquals("val", cache.get("key"));
}
use of io.druid.query.lookup.namespace.URIExtractionNamespace in project druid by druid-io.
the class NamespaceLookupExtractorFactoryTest method testSimpleSerde.
@Test
public void testSimpleSerde() throws Exception {
final URIExtractionNamespace uriExtractionNamespace = new URIExtractionNamespace(temporaryFolder.newFolder().toURI(), null, null, new URIExtractionNamespace.ObjectMapperFlatDataParser(mapper), Period.millis(0), null);
final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(uriExtractionNamespace, scheduler);
Assert.assertEquals(uriExtractionNamespace, mapper.readValue(mapper.writeValueAsString(namespaceLookupExtractorFactory), NamespaceLookupExtractorFactory.class).getExtractionNamespace());
}
use of io.druid.query.lookup.namespace.URIExtractionNamespace in project druid by druid-io.
the class NamespacedExtractorModuleTest method testNewUpdate.
@Test
public void testNewUpdate() throws Exception {
final File tmpFile = temporaryFolder.newFile();
try (OutputStreamWriter out = new FileWriter(tmpFile)) {
out.write(mapper.writeValueAsString(ImmutableMap.<String, String>of("foo", "bar")));
}
final URIExtractionNamespace namespace = new URIExtractionNamespace(tmpFile.toURI(), null, null, new URIExtractionNamespace.ObjectMapperFlatDataParser(URIExtractionNamespaceTest.registerTypes(new DefaultObjectMapper())), new Period(0), null);
Assert.assertEquals(0, scheduler.getActiveEntries());
try (CacheScheduler.Entry entry = scheduler.scheduleAndWait(namespace, 10_000)) {
Assert.assertNotNull(entry);
entry.awaitTotalUpdates(1);
Assert.assertEquals(1, scheduler.getActiveEntries());
}
}
use of io.druid.query.lookup.namespace.URIExtractionNamespace in project druid by druid-io.
the class URIExtractionNamespaceCacheFactoryTest method testWeirdSchemaOnExactURI.
@Test
public void testWeirdSchemaOnExactURI() throws Exception {
final URIExtractionNamespace extractionNamespace = new URIExtractionNamespace(new URI(FAKE_SCHEME, namespace.getUri().getUserInfo(), namespace.getUri().getHost(), namespace.getUri().getPort(), namespace.getUri().getPath(), namespace.getUri().getQuery(), namespace.getUri().getFragment()), null, null, namespace.getNamespaceParseSpec(), Period.millis((int) namespace.getPollMs()), null);
Assert.assertNotNull(populator.populateCache(extractionNamespace, null, null, scheduler));
}
use of io.druid.query.lookup.namespace.URIExtractionNamespace in project druid by druid-io.
the class URIExtractionNamespaceCacheFactoryTest method testMissing.
@Test(expected = FileNotFoundException.class)
public void testMissing() throws Exception {
URIExtractionNamespace badNamespace = new URIExtractionNamespace(namespace.getUri(), null, null, namespace.getNamespaceParseSpec(), Period.millis((int) namespace.getPollMs()), null);
Assert.assertTrue(new File(namespace.getUri()).delete());
populator.populateCache(badNamespace, null, null, scheduler);
}
Aggregations