use of io.druid.query.lookup.namespace.URIExtractionNamespace in project druid by druid-io.
the class URIExtractionNamespaceCacheFactoryTest method testDeleteOnScheduleFail.
@Test(timeout = 10_000)
public void testDeleteOnScheduleFail() throws Exception {
Assert.assertNull(scheduler.scheduleAndWait(new URIExtractionNamespace(new URI("file://tmp/I_DONT_REALLY_EXIST" + UUID.randomUUID().toString()), null, null, new URIExtractionNamespace.JSONFlatDataParser(new DefaultObjectMapper(), "key", "val"), Period.millis(10000), null), 500));
Assert.assertEquals(0, scheduler.getActiveEntries());
}
use of io.druid.query.lookup.namespace.URIExtractionNamespace in project druid by druid-io.
the class URIExtractionNamespaceCacheFactoryTest method setUp.
@Before
public void setUp() throws Exception {
lifecycle.start();
tmpFileParent = new File(temporaryFolder.newFolder(), "☃");
Assert.assertTrue(tmpFileParent.mkdir());
Assert.assertTrue(tmpFileParent.isDirectory());
tmpFile = Files.createTempFile(tmpFileParent.toPath(), "druidTestURIExtractionNS", suffix).toFile();
final ObjectMapper mapper = new DefaultObjectMapper();
try (OutputStream ostream = outStreamSupplier.apply(tmpFile)) {
try (OutputStreamWriter out = new OutputStreamWriter(ostream)) {
out.write(mapper.writeValueAsString(ImmutableMap.<String, String>of("boo", "bar", "foo", "bar", "", "MissingValue", "emptyString", "")));
}
}
populator = new URIExtractionNamespaceCacheFactory(FINDERS);
namespace = new URIExtractionNamespace(tmpFile.toURI(), null, null, new URIExtractionNamespace.ObjectMapperFlatDataParser(URIExtractionNamespaceTest.registerTypes(new ObjectMapper())), new Period(0), null);
}
use of io.druid.query.lookup.namespace.URIExtractionNamespace in project druid by druid-io.
the class NamespacedExtractorModuleTest method testNewTask.
@Test
public void testNewTask() throws Exception {
final File tmpFile = temporaryFolder.newFile();
try (OutputStreamWriter out = new FileWriter(tmpFile)) {
out.write(mapper.writeValueAsString(ImmutableMap.<String, String>of("foo", "bar")));
}
final URIExtractionNamespaceCacheFactory factory = new URIExtractionNamespaceCacheFactory(ImmutableMap.<String, SearchableVersionedDataFinder>of("file", new LocalFileTimestampVersionFinder()));
final URIExtractionNamespace namespace = new URIExtractionNamespace(tmpFile.toURI(), null, null, new URIExtractionNamespace.ObjectMapperFlatDataParser(URIExtractionNamespaceTest.registerTypes(new DefaultObjectMapper())), new Period(0), null);
CacheScheduler.VersionedCache versionedCache = factory.populateCache(namespace, null, null, scheduler);
Assert.assertNotNull(versionedCache);
Map<String, String> map = versionedCache.getCache();
Assert.assertEquals("bar", map.get("foo"));
Assert.assertEquals(null, map.get("baz"));
}
Aggregations