Search in sources :

Example 6 with ExtractionNamespace

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();
}
Also used : ExtractionNamespace(io.druid.query.lookup.namespace.ExtractionNamespace) URIExtractionNamespace(io.druid.query.lookup.namespace.URIExtractionNamespace) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with ExtractionNamespace

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();
}
Also used : ExtractionNamespace(io.druid.query.lookup.namespace.ExtractionNamespace) URIExtractionNamespace(io.druid.query.lookup.namespace.URIExtractionNamespace) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 8 with ExtractionNamespace

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();
}
Also used : ExtractionNamespace(io.druid.query.lookup.namespace.ExtractionNamespace) URIExtractionNamespace(io.druid.query.lookup.namespace.URIExtractionNamespace) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 9 with ExtractionNamespace

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();
}
Also used : Response(javax.ws.rs.core.Response) ExtractionNamespace(io.druid.query.lookup.namespace.ExtractionNamespace) URIExtractionNamespace(io.druid.query.lookup.namespace.URIExtractionNamespace) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 10 with ExtractionNamespace

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);
}
Also used : ExtractionNamespace(io.druid.query.lookup.namespace.ExtractionNamespace) URIExtractionNamespace(io.druid.query.lookup.namespace.URIExtractionNamespace) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ExtractionNamespace (io.druid.query.lookup.namespace.ExtractionNamespace)14 URIExtractionNamespace (io.druid.query.lookup.namespace.URIExtractionNamespace)13 Test (org.junit.Test)11 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)11 Lifecycle (io.druid.java.util.common.lifecycle.Lifecycle)3 ExtractionNamespaceCacheFactory (io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory)3 NoopServiceEmitter (io.druid.server.metrics.NoopServiceEmitter)3 Before (org.junit.Before)3 CacheScheduler (io.druid.server.lookup.namespace.cache.CacheScheduler)2 OnHeapNamespaceExtractionCacheManager (io.druid.server.lookup.namespace.cache.OnHeapNamespaceExtractionCacheManager)2 SearchableVersionedDataFinder (io.druid.data.SearchableVersionedDataFinder)1 ISE (io.druid.java.util.common.ISE)1 JDBCExtractionNamespace (io.druid.query.lookup.namespace.JDBCExtractionNamespace)1 StaticMapExtractionNamespace (io.druid.query.lookup.namespace.StaticMapExtractionNamespace)1 LocalFileTimestampVersionFinder (io.druid.segment.loading.LocalFileTimestampVersionFinder)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Path (java.nio.file.Path)1 Response (javax.ws.rs.core.Response)1