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