Search in sources :

Example 26 with SerializableRunnableIF

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

the class LuceneQueriesClientDUnitTest method transactionWithLuceneQueriesShouldThrowException.

// Due to singlehop transactions differences, the exception actually isn't thrown
// So the parent test behaves differently if singlehop is enabled or not for a client
@Test
@Parameters(method = "getListOfRegionTestTypes")
public void transactionWithLuceneQueriesShouldThrowException(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));
    accessor.invoke(() -> {
        Cache cache = getCache();
        try {
            LuceneService service = LuceneServiceProvider.get(cache);
            LuceneQuery<Integer, TestObject> query;
            query = service.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "text:world", DEFAULT_FIELD);
            cache.getCacheTransactionManager().begin();
            PageableLuceneQueryResults<Integer, TestObject> results = query.findPages();
        } finally {
            cache.getCacheTransactionManager().rollback();
        }
    });
}
Also used : SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 27 with SerializableRunnableIF

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

the class LuceneQueriesDUnitTest method returnCorrectResultsFromStringQueryWithDefaultAnalyzer.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void returnCorrectResultsFromStringQueryWithDefaultAnalyzer(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));
    executeTextSearch(accessor);
}
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 28 with SerializableRunnableIF

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

the class LuceneQueriesDUnitTest method defaultFieldShouldPropogateCorrectlyThroughFunction.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void defaultFieldShouldPropogateCorrectlyThroughFunction(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));
    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 29 with SerializableRunnableIF

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

the class LuceneQueriesDUnitTest method transactionWithLuceneQueriesShouldThrowException.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void transactionWithLuceneQueriesShouldThrowException(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));
    accessor.invoke(() -> {
        Cache cache = getCache();
        try {
            LuceneService service = LuceneServiceProvider.get(cache);
            LuceneQuery<Integer, TestObject> query;
            query = service.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "text:world", DEFAULT_FIELD);
            cache.getCacheTransactionManager().begin();
            PageableLuceneQueryResults<Integer, TestObject> results = query.findPages();
            fail();
        } catch (LuceneQueryException e) {
            if (!e.getMessage().equals(LuceneQueryImpl.LUCENE_QUERY_CANNOT_BE_EXECUTED_WITHIN_A_TRANSACTION)) {
                fail();
            }
        } finally {
            cache.getCacheTransactionManager().rollback();
        }
    });
}
Also used : 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 30 with SerializableRunnableIF

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

the class LuceneQueriesDUnitTest method verifyWildcardQueriesSucceed.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void verifyWildcardQueriesSucceed(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));
    executeTextSearch(accessor, "*", "*", 3);
    executeTextSearch(accessor, "*:*", "text", 3);
    executeTextSearch(accessor, "*:*", "XXX", 3);
    executeTextSearch(accessor, "*", "text", 3);
}
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