geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject [1/2] incubator-geode git commit: GEODE-11: Adding a dunit test of querying with a custom query object
Date Wed, 22 Jun 2016 01:11:56 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 087da4e3d -> 588269395


GEODE-11: Adding a dunit test of querying with a custom query object


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/d25dd3fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/d25dd3fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/d25dd3fe

Branch: refs/heads/develop
Commit: d25dd3fe61a67027d10ebcb6b11f3b2ecf6cf444
Parents: 087da4e
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Wed Jun 15 15:33:13 2016 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Tue Jun 21 18:03:38 2016 -0700

----------------------------------------------------------------------
 .../gemfire/cache/lucene/LuceneQueriesBase.java | 26 ++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d25dd3fe/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesBase.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesBase.java
b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesBase.java
index 2fdf531..f077bad 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesBase.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneQueriesBase.java
@@ -33,6 +33,8 @@ import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.SerializableRunnableIF;
 import com.gemstone.gemfire.test.dunit.VM;
 
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.TermQuery;
 import org.junit.Test;
 
 /**
@@ -85,6 +87,30 @@ public abstract class LuceneQueriesBase extends LuceneDUnitTest {
   }
 
   @Test
+  public void canQueryWithCustomLuceneQueryObject() {
+    SerializableRunnableIF createIndex = () -> {
+      LuceneService luceneService = LuceneServiceProvider.get(getCache());
+      luceneService.createIndex(INDEX_NAME, REGION_NAME, "text");
+    };
+    dataStore1.invoke(() -> initDataStore(createIndex));
+    dataStore2.invoke(() -> initDataStore(createIndex));
+    accessor.invoke(() -> initAccessor(createIndex));
+    putDataInRegion(accessor);
+    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 LuceneQueryResults results = query.search();
+      assertEquals(3, results.size());
+    });
+  }
+
+  @Test
   public void entriesFlushedToIndexAfterWaitForFlushCalled() {
     SerializableRunnableIF createIndex = () -> {
       LuceneService luceneService = LuceneServiceProvider.get(getCache());


Mime
View raw message