Search in sources :

Example 11 with TestObject

use of org.apache.geode.cache.lucene.test.TestObject in project geode by apache.

the class LuceneIndexCreationPersistenceIntegrationTest method shouldHandleMultipleIndexes.

@Test
@Parameters(method = "getRegionShortcuts")
public void shouldHandleMultipleIndexes(RegionShortcut shortcut) throws Exception {
    LuceneServiceProvider.get(this.cache).createIndexFactory().setFields("field1").create(INDEX_NAME + "_1", REGION_NAME);
    LuceneServiceProvider.get(this.cache).createIndexFactory().setFields("field2").create(INDEX_NAME + "_2", REGION_NAME);
    Region region = cache.createRegionFactory(shortcut).create(REGION_NAME);
    region.put("key1", new TestObject());
    verifyQueryResultSize(INDEX_NAME + "_1", REGION_NAME, "field1:world", DEFAULT_FIELD, 1);
    verifyQueryResultSize(INDEX_NAME + "_2", REGION_NAME, "field2:field", DEFAULT_FIELD, 1);
}
Also used : LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) TestObject(org.apache.geode.cache.lucene.test.TestObject) Parameters(junitparams.Parameters) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 12 with TestObject

use of org.apache.geode.cache.lucene.test.TestObject in project geode by apache.

the class LuceneIndexCreationPersistenceIntegrationTest method shouldRecoverPersistentIndexWhenDataIsWrittenToIndex.

@Test
public void shouldRecoverPersistentIndexWhenDataIsWrittenToIndex() throws Exception {
    createIndex(cache, "field1", "field2");
    Region dataRegion = cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT).create(REGION_NAME);
    dataRegion.put("A", new TestObject());
    verifyIndexFinishFlushing(cache, INDEX_NAME, REGION_NAME);
    cache.close();
    createCache();
    createIndex(cache, "field1", "field2");
    dataRegion = cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT).create(REGION_NAME);
    LuceneQuery<Object, Object> query = luceneService.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "field1:world", DEFAULT_FIELD);
    assertEquals(1, query.findPages().size());
}
Also used : LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) TestObject(org.apache.geode.cache.lucene.test.TestObject) TestObject(org.apache.geode.cache.lucene.test.TestObject) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 13 with TestObject

use of org.apache.geode.cache.lucene.test.TestObject in project geode by apache.

the class LuceneIndexCreationPersistenceIntegrationTest method shouldRecoverPersistentIndexWhenDataStillInQueue.

@Test
public void shouldRecoverPersistentIndexWhenDataStillInQueue() throws Exception {
    createIndex(cache, "field1", "field2");
    Region dataRegion = cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT).create(REGION_NAME);
    // Pause the sender so that the entry stays in the queue
    pauseSender(cache);
    dataRegion.put("A", new TestObject());
    cache.close();
    createCache();
    createIndex(cache, "field1", "field2");
    dataRegion = cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT).create(REGION_NAME);
    verifyIndexFinishFlushing(cache, INDEX_NAME, REGION_NAME);
    LuceneQuery<Object, Object> query = luceneService.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "field1:world", DEFAULT_FIELD);
    assertEquals(1, query.findPages().size());
}
Also used : LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) TestObject(org.apache.geode.cache.lucene.test.TestObject) TestObject(org.apache.geode.cache.lucene.test.TestObject) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

TestObject (org.apache.geode.cache.lucene.test.TestObject)13 Region (org.apache.geode.cache.Region)11 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)11 Test (org.junit.Test)11 HashMap (java.util.HashMap)6 LocalRegion (org.apache.geode.internal.cache.LocalRegion)6 Analyzer (org.apache.lucene.analysis.Analyzer)6 KeywordAnalyzer (org.apache.lucene.analysis.core.KeywordAnalyzer)4 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)4 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 TimeUnit (java.util.concurrent.TimeUnit)1 Parameters (junitparams.Parameters)1 CacheLoader (org.apache.geode.cache.CacheLoader)1 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)1 LoaderHelper (org.apache.geode.cache.LoaderHelper)1 RegionShortcut (org.apache.geode.cache.RegionShortcut)1 LuceneIntegrationTest (org.apache.geode.cache.lucene.LuceneIntegrationTest)1 InternalLuceneIndex (org.apache.geode.cache.lucene.internal.InternalLuceneIndex)1