incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/2] git commit: Fixing unit test.
Date Thu, 16 Jan 2014 18:14:56 GMT
Updated Branches:
  refs/heads/apache-blur-0.2 8e40f7b66 -> 76c55cc01


Fixing unit test.


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

Branch: refs/heads/apache-blur-0.2
Commit: bd28c8a460077b5642a44b48529849121cc44544
Parents: 8e40f7b
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Thu Jan 16 13:00:55 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Thu Jan 16 13:00:55 2014 -0500

----------------------------------------------------------------------
 .../manager/writer/MutatableActionTest.java     | 41 ++++++++++++++------
 1 file changed, 29 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/bd28c8a4/blur-core/src/test/java/org/apache/blur/manager/writer/MutatableActionTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/writer/MutatableActionTest.java
b/blur-core/src/test/java/org/apache/blur/manager/writer/MutatableActionTest.java
index 90ad9e5..3f3e993 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/writer/MutatableActionTest.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/writer/MutatableActionTest.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
 
+import org.apache.blur.server.IndexSearcherClosable;
 import org.apache.blur.server.ShardContext;
 import org.apache.blur.server.TableContext;
 import org.apache.blur.thrift.generated.Column;
@@ -41,6 +42,7 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.Version;
 import org.junit.Before;
@@ -96,7 +98,7 @@ public class MutatableActionTest {
 
     Row row = genRow();
     _action.replaceRow(row);
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(1, reader.numDocs());
 
@@ -106,11 +108,26 @@ public class MutatableActionTest {
     row2.addToRecords(new Record("1", "fam", cols));
 
     _action.replaceRow(row2);
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(2, reader.numDocs());
   }
 
+  private IndexSearcherClosable getSearcher(DirectoryReader reader, final Directory directory)
{
+    return new IndexSearcherClosable(reader, null) {
+
+      @Override
+      public Directory getDirectory() {
+        return directory;
+      }
+
+      @Override
+      public void close() throws IOException {
+
+      }
+    };
+  }
+
   @Test
   public void testDeleteRecord() throws IOException {
     RAMDirectory directory = new RAMDirectory();
@@ -124,12 +141,12 @@ public class MutatableActionTest {
     row.addToRecords(new Record("1", "fam", cols));
 
     _action.replaceRow(row);
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(2, reader.numDocs());
 
     _action.deleteRecord(row.getId(), "1");
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(1, reader.numDocs());
   }
@@ -143,12 +160,12 @@ public class MutatableActionTest {
 
     Row row = genRow();
     _action.replaceRow(row);
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(1, reader.numDocs());
 
     _action.deleteRow(row.getId());
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(0, reader.numDocs());
   }
@@ -166,14 +183,14 @@ public class MutatableActionTest {
     row.addToRecords(new Record("1", "fam", cols));
 
     _action.replaceRow(row);
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(2, reader.numDocs());
 
     cols.add(new Column("n2", "v2"));
     Record record = new Record("1", "fam", cols);
     _action.replaceRecord(row.getId(), record);
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(2, reader.numDocs());
 
@@ -199,7 +216,7 @@ public class MutatableActionTest {
     row.addToRecords(new Record("1", "fam", cols));
 
     _action.replaceRow(row);
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(2, reader.numDocs());
 
@@ -207,7 +224,7 @@ public class MutatableActionTest {
     cols.add(new Column("n2", "v2"));
     Record record = new Record("1", "fam", cols);
     _action.appendColumns(row.getId(), record);
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(2, reader.numDocs());
 
@@ -234,7 +251,7 @@ public class MutatableActionTest {
     row.addToRecords(new Record("1", "fam", cols));
 
     _action.replaceRow(row);
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(2, reader.numDocs());
 
@@ -242,7 +259,7 @@ public class MutatableActionTest {
     cols.add(new Column("n1", "v2"));
     Record record = new Record("1", "fam", cols);
     _action.replaceColumns(row.getId(), record);
-    _action.performMutate(reader, writer);
+    _action.performMutate(getSearcher(reader, directory), writer);
     reader = commitAndReopen(reader, writer);
     assertEquals(2, reader.numDocs());
 


Mime
View raw message