jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1471042 [2/2] - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/commit/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/nodet...
Date Tue, 23 Apr 2013 17:06:58 GMT
Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java?rev=1471042&r1=1471041&r2=1471042&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
Tue Apr 23 17:06:54 2013
@@ -20,15 +20,18 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertTrue;
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
+import static org.apache.jackrabbit.JcrConstants.NT_BASE;
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
+import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_NODE_TYPES;
 
 import org.apache.jackrabbit.oak.plugins.index.IndexDefinition;
 import org.apache.jackrabbit.oak.plugins.index.IndexDefinitionImpl;
+import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
 import org.apache.jackrabbit.oak.query.ast.Operator;
+import org.apache.jackrabbit.oak.query.ast.SelectorImpl;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
-import org.apache.jackrabbit.oak.spi.commit.Editor;
-import org.apache.jackrabbit.oak.spi.commit.EditorHook;
-import org.apache.jackrabbit.oak.spi.commit.EditorProvider;
+import org.apache.jackrabbit.oak.spi.commit.EditorDiff;
 import org.apache.jackrabbit.oak.spi.query.Cursor;
 import org.apache.jackrabbit.oak.spi.query.Filter;
 import org.apache.jackrabbit.oak.spi.query.PropertyValues;
@@ -39,11 +42,12 @@ import org.junit.Test;
 
 public class LuceneIndexTest implements LuceneIndexConstants {
 
+    private NodeState root = new InitialContent().initialize(EMPTY_NODE);
+
+    private NodeBuilder builder = root.builder();
+
     @Test
     public void testLucene() throws Exception {
-        NodeState root = EMPTY_NODE;
-
-        NodeBuilder builder = root.builder();
         builder.child("oak:index").child("lucene")
                 .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE)
                 .setProperty("type", TYPE_LUCENE);
@@ -52,20 +56,13 @@ public class LuceneIndexTest implements 
         builder.setProperty("foo", "bar");
         NodeState after = builder.getNodeState();
 
-        EditorProvider provider = new EditorProvider() {
-            @Override
-            public Editor getRootEditor(NodeState before, NodeState after,
-                    NodeBuilder builder) {
-                return new LuceneIndexDiff(builder);
-            }
-        };
-        EditorHook hook = new EditorHook(provider);
-        NodeState indexed = hook.processCommit(before, after);
+        EditorDiff.process(new LuceneIndexDiff(builder), before, after);
+        NodeState indexed = builder.getNodeState();
 
         IndexDefinition testDef = new IndexDefinitionImpl("lucene",
                 TYPE_LUCENE, "/oak:index/lucene");
         QueryIndex queryIndex = new LuceneIndex(testDef);
-        FilterImpl filter = new FilterImpl(null, null);
+        FilterImpl filter = createFilter(NT_BASE);
         filter.restrictPath("/", Filter.PathRestriction.EXACT);
         filter.restrictProperty("foo", Operator.EQUAL,
                 PropertyValues.newString("bar"));
@@ -77,9 +74,6 @@ public class LuceneIndexTest implements 
 
     @Test
     public void testLucene2() throws Exception {
-        NodeState root = EMPTY_NODE;
-
-        NodeBuilder builder = root.builder();
         builder.child("oak:index").child("lucene")
                 .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE)
                 .setProperty("type", TYPE_LUCENE);
@@ -92,20 +86,13 @@ public class LuceneIndexTest implements 
 
         NodeState after = builder.getNodeState();
 
-        EditorProvider provider = new EditorProvider() {
-            @Override
-            public Editor getRootEditor(NodeState before, NodeState after,
-                    NodeBuilder builder) {
-                return new LuceneIndexDiff(builder);
-            }
-        };
-        EditorHook hook = new EditorHook(provider);
-        NodeState indexed = hook.processCommit(before, after);
+        EditorDiff.process(new LuceneIndexDiff(builder), before, after);
+        NodeState indexed = builder.getNodeState();
 
         IndexDefinition testDef = new IndexDefinitionImpl("lucene",
                 TYPE_LUCENE, "/oak:index/lucene");
         QueryIndex queryIndex = new LuceneIndex(testDef);
-        FilterImpl filter = new FilterImpl(null, null);
+        FilterImpl filter = createFilter(NT_BASE);
         // filter.restrictPath("/", Filter.PathRestriction.EXACT);
         filter.restrictProperty("foo", Operator.EQUAL,
                 PropertyValues.newString("bar"));
@@ -119,4 +106,12 @@ public class LuceneIndexTest implements 
         assertFalse(cursor.hasNext());
     }
 
+    private FilterImpl createFilter(String nodeTypeName) {
+        NodeState system = root.getChildNode(JCR_SYSTEM);
+        NodeState types = system.getChildNode(JCR_NODE_TYPES);
+        NodeState type = types.getChildNode(nodeTypeName);
+        SelectorImpl selector = new SelectorImpl(type, nodeTypeName);
+        return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]");
+    }
+
 }



Mime
View raw message