Search in sources :

Example 11 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class LuceneIndexCreationDUnitTest method verifyDifferentIndexNamesFails.

@Test
@Parameters({ "PARTITION" })
public void verifyDifferentIndexNamesFails(RegionTestableType regionType) {
    SerializableRunnableIF createIndex1 = () -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        luceneService.createIndexFactory().addField("field1").create(INDEX_NAME + "1", REGION_NAME);
    };
    dataStore1.invoke(() -> initDataStore(createIndex1, regionType));
    SerializableRunnableIF createIndex2 = () -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        luceneService.createIndexFactory().addField("field1").create(INDEX_NAME + "2", REGION_NAME);
    };
    dataStore2.invoke(() -> initDataStore(createIndex2, regionType, CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_NAMES));
}
Also used : SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 12 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class LuceneQueriesDUnitTest method canQueryWithCustomLuceneQueryObject.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void canQueryWithCustomLuceneQueryObject(RegionTestableType regionTestType) {
    SerializableRunnableIF createIndex = () -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        luceneService.createIndexFactory().addField("text").create(INDEX_NAME, REGION_NAME);
    };
    dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
    dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
    accessor.invoke(() -> initAccessor(createIndex, regionTestType));
    putDataInRegion(accessor);
    assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000));
    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000));
    // Execute a query with a custom lucene query object
    accessor.invoke(() -> {
        Cache cache = getCache();
        LuceneService service = LuceneServiceProvider.get(cache);
        LuceneQuery query = service.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, index -> {
            return new TermQuery(new Term("text", "world"));
        });
        final PageableLuceneQueryResults results = query.findPages();
        assertEquals(3, results.size());
    });
}
Also used : TermQuery(org.apache.lucene.search.TermQuery) Term(org.apache.lucene.index.Term) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Cache(org.apache.geode.cache.Cache) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 13 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class LuceneQueriesDUnitTest method verifySpaceQueriesFail.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void verifySpaceQueriesFail(RegionTestableType regionTestType) {
    SerializableRunnableIF createIndex = () -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        luceneService.createIndexFactory().addField("text").create(INDEX_NAME, REGION_NAME);
    };
    dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
    dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
    accessor.invoke(() -> initAccessor(createIndex, regionTestType));
    putDataInRegion(accessor);
    assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000));
    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000));
    executeTextSearchWithExpectedException(accessor, " ", "*", LuceneQueryException.class);
    executeTextSearchWithExpectedException(accessor, " ", "text", LuceneQueryException.class);
    executeTextSearchWithExpectedException(accessor, " ", "XXX", LuceneQueryException.class);
}
Also used : SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 14 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class LuceneQueriesDUnitTest method verifyWaitForFlushedFunctionOnAccessor.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void verifyWaitForFlushedFunctionOnAccessor(RegionTestableType regionTestType) throws InterruptedException {
    SerializableRunnableIF createIndex = () -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        luceneService.createIndexFactory().addField("text").create(INDEX_NAME, REGION_NAME);
    };
    dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
    dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
    accessor.invoke(() -> initAccessor(createIndex, regionTestType));
    dataStore1.invoke(() -> LuceneTestUtilities.pauseSender(getCache()));
    dataStore2.invoke(() -> LuceneTestUtilities.pauseSender(getCache()));
    putDataInRegion(accessor);
    assertFalse(waitForFlushBeforeExecuteTextSearch(accessor, 200));
    dataStore1.invoke(() -> LuceneTestUtilities.resumeSender(getCache()));
    dataStore2.invoke(() -> LuceneTestUtilities.resumeSender(getCache()));
    assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000));
    executeTextSearch(accessor, "world", "text", 3);
    executeTextSearch(accessor, "world", "noEntriesMapped", 0);
}
Also used : SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 15 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class LuceneIndexCreationDUnitTest method verifyDifferentFieldsFails.

@Test
@Parameters({ "PARTITION" })
public void verifyDifferentFieldsFails(RegionTestableType regionType) {
    SerializableRunnableIF createIndex1 = getFieldsIndexWithOneField();
    dataStore1.invoke(() -> initDataStore(createIndex1, regionType));
    SerializableRunnableIF createIndex2 = getFieldsIndexWithTwoFields();
    dataStore2.invoke(() -> initDataStore(createIndex2, regionType, CANNOT_CREATE_LUCENE_INDEX_DIFFERENT_FIELDS));
}
Also used : SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

SerializableRunnableIF (org.apache.geode.test.dunit.SerializableRunnableIF)49 Test (org.junit.Test)45 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)44 Parameters (junitparams.Parameters)39 Cache (org.apache.geode.cache.Cache)12 Region (org.apache.geode.cache.Region)12 List (java.util.List)7 ClientCache (org.apache.geode.cache.client.ClientCache)6 Host (org.apache.geode.test.dunit.Host)6 VM (org.apache.geode.test.dunit.VM)6 ArrayList (java.util.ArrayList)5 CacheException (org.apache.geode.cache.CacheException)5 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)5 AbstractIndex (org.apache.geode.cache.query.internal.index.AbstractIndex)5 IOException (java.io.IOException)4 Collection (java.util.Collection)4 HashSet (java.util.HashSet)4 CancellationException (java.util.concurrent.CancellationException)4 DataInput (java.io.DataInput)3 DataOutput (java.io.DataOutput)3