Changing the way LuceneFunctionReadPathDUnitTest uses the collector

The test should call getResult on the returned ResultCollector, not the
one provided to the FunctionService. I saw this test hang on my machine
and I'm not sure if this is the cause or not, but this is the way the
collector is supposed to be used, according to the javadocs.

Also, adding a timeout to the call so that if the test hangs again, it
will fail with a timeout.


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

Branch: refs/heads/develop
Commit: 0394f0527fb613f465e92ad88a1960d1e66e3191
Parents: 74512e5
Author: Dan Smith <[email protected]>
Authored: Tue Sep 22 15:35:34 2015 -0700
Committer: Dan Smith <[email protected]>
Committed: Tue Sep 22 15:35:34 2015 -0700

----------------------------------------------------------------------
 .../LuceneFunctionReadPathDUnitTest.java        | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0394f052/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java
----------------------------------------------------------------------
diff --git 
a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java
 
b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java
index 55c20cc..a950c8d 100644
--- 
a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java
+++ 
b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java
@@ -1,11 +1,12 @@
 package com.gemstone.gemfire.cache.lucene.internal.distributed;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.lucene.search.Query;
 import org.junit.Assert;
@@ -18,7 +19,9 @@ import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionFactory;
 import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.execute.FunctionException;
 import com.gemstone.gemfire.cache.execute.FunctionService;
+import com.gemstone.gemfire.cache.execute.ResultCollector;
 import com.gemstone.gemfire.cache.lucene.LuceneIndex;
 import com.gemstone.gemfire.cache.lucene.LuceneQueryProvider;
 import com.gemstone.gemfire.cache.lucene.LuceneService;
@@ -118,10 +121,15 @@ public class LuceneFunctionReadPathDUnitTest extends 
CacheTestCase {
             new TopEntriesCollectorManager());
         TopEntriesFunctionCollector collector = new 
TopEntriesFunctionCollector();
 
-        
FunctionService.onRegion(region).withArgs(context).withCollector(collector).execute(LuceneFunction.ID);
-        TopEntries entries = collector.getResult();
-        assertNotNull(entries);
-        assertEquals(2, entries.getHits().size());
+        ResultCollector<TopEntriesCollector, TopEntries> rc = 
(ResultCollector<TopEntriesCollector, TopEntries>) 
FunctionService.onRegion(region).withArgs(context).withCollector(collector).execute(LuceneFunction.ID);
+        TopEntries entries;
+        try {
+          entries = rc.getResult(30, TimeUnit.SECONDS);
+          assertNotNull(entries);
+          assertEquals(2, entries.getHits().size());
+        } catch (Exception e) {
+          fail("failed", e);
+        }
       }
     };
 

Reply via email to