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();
}
});
}
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);
}
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);
}
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();
}
});
}
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);
}
Aggregations