jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1407425 [2/2] - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/index/ main/java/org/apache/jackrabbit/oak/plugins/index/lucene/ main/java/org/apache/jackrabbit/oak/plugins/index/property/ test/java/org/a...
Date Fri, 09 Nov 2012 11:26:35 GMT
Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiffTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiffTest.java?rev=1407425&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiffTest.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiffTest.java
Fri Nov  9 11:26:30 2012
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index;
+
+import static com.google.common.collect.Sets.difference;
+import static com.google.common.collect.Sets.newHashSet;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexHookProvider;
+import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
+import org.junit.Test;
+
+public class IndexHookManagerDiffTest {
+
+    @Test
+    public void testIndexDefinitions() throws Exception {
+        NodeState root = MemoryNodeState.EMPTY_NODE;
+
+        NodeBuilder builder = root.builder();
+        // this index is on the current update branch, it should be seen by the
+        // diff
+        builder.child("oak:index")
+                .child("existing")
+                .setProperty("type", "property")
+                .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE,
+                        Type.NAME);
+        // this index is NOT the current update branch, it should NOT be seen by
+        // the diff
+        builder.child("newchild")
+                .child("other")
+                .child("oak:index")
+                .child("existing2")
+                .setProperty("type", "property")
+                .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE,
+                        Type.NAME);
+
+        NodeState before = builder.getNodeState();
+        // Add index definition
+        builder.child("oak:index")
+                .child("foo")
+                .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE,
+                        Type.NAME);
+        builder.child("test")
+                .child("other")
+                .child("oak:index")
+                .child("index2")
+                .setProperty("type", "property")
+                .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE,
+                        Type.NAME);
+        NodeState after = builder.getNodeState();
+
+        IndexHookProvider provider = new CompositeIndexHookProvider(
+                new PropertyIndexHookProvider());
+
+        // <type, <path, indexhook>>
+        Map<String, Map<String, List<IndexHook>>> updates = new HashMap<String,
Map<String, List<IndexHook>>>();
+        NodeStateDiff diff = new IndexHookManagerDiff(provider, builder,
+                updates);
+        after.compareAgainstBaseState(before, diff);
+
+        for (String type : updates.keySet()) {
+            for (List<IndexHook> hooks : updates.get(type).values()) {
+                for (IndexHook hook : hooks) {
+                    hook.apply();
+                }
+            }
+        }
+
+        Set<String> expected = newHashSet("/", "/test/other");
+        Set<String> found = updates.remove("property").keySet();
+        assertTrue("Expecting " + expected + " got " + found,
+                difference(found, expected).isEmpty());
+        assertTrue(updates.isEmpty());
+
+        NodeState indexed = builder.getNodeState();
+
+        // check that the index content nodes exist
+        checkPathExists(indexed, "oak:index", "existing", ":index");
+        checkPathExists(indexed, "test", "other", "oak:index", "index2",
+                ":index");
+        NodeState ignoredIndex = checkPathExists(indexed, "newchild", "other",
+                "oak:index", "existing2");
+        assertFalse(ignoredIndex.hasChildNode(":index"));
+    }
+
+    private static NodeState checkPathExists(NodeState state, String... verify) {
+        NodeState c = state;
+        for (String p : verify) {
+            assertTrue(c.hasChildNode(p));
+            c = c.getChildNode(p);
+        }
+        return c;
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiffTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerDiffTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java?rev=1407425&r1=1407424&r2=1407425&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
Fri Nov  9 11:26:30 2012
@@ -18,110 +18,215 @@ package org.apache.jackrabbit.oak.plugin
 
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE;
+import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
+import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.index.IndexHookManager.IndexDefDiff;
+import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexHookProvider;
+import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexLookup;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.junit.Test;
 
-import com.google.common.collect.Lists;
+import com.google.common.collect.ImmutableSet;
 
 public class IndexHookManagerTest {
 
+    /**
+     * Simple Test
+     * <ul>
+     * <li>Add an index definition</li>
+     * <li>Add some content</li>
+     * <li>Search & verify</li>
+     * </ul>
+     * 
+     */
     @Test
     public void test() throws Exception {
         NodeState root = MemoryNodeState.EMPTY_NODE;
 
         NodeBuilder builder = root.builder();
-        // this index is on the current update branch, it should be seen by the
-        // diff
+
         builder.child("oak:index")
-                .child("existing")
+                .child("rootIndex")
+                .setProperty("propertyNames", "foo")
+                .setProperty("type", "property")
                 .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE,
                         Type.NAME);
-        // this index is NOT the current update branch, it should NOT be seen by
-        // the diff
         builder.child("newchild")
                 .child("other")
                 .child("oak:index")
-                .child("existing2")
+                .child("subIndex")
+                .setProperty("propertyNames", "foo")
+                .setProperty("type", "property")
                 .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE,
                         Type.NAME);
 
         NodeState before = builder.getNodeState();
-        // Add index definition
+        // Add nodes
+        builder.child("testRoot").setProperty("foo", "abc");
+        builder.child("newchild").child("other").child("testChild")
+                .setProperty("foo", "xyz");
+
+        NodeState after = builder.getNodeState();
+
+        IndexHookManager im = new IndexHookManager(
+                new CompositeIndexHookProvider(new PropertyIndexHookProvider()));
+        NodeState indexed = im.processCommit(before, after);
+
+        // first check that the index content nodes exist
+        checkPathExists(indexed, "oak:index", "rootIndex", ":index");
+        checkPathExists(indexed, "newchild", "other", "oak:index", "subIndex",
+                ":index");
+
+        PropertyIndexLookup lookup = new PropertyIndexLookup(indexed);
+        assertEquals(ImmutableSet.of("testRoot"), lookup.find("foo", "abc"));
+
+        PropertyIndexLookup lookupChild = new PropertyIndexLookup(indexed
+                .getChildNode("newchild").getChildNode("other"));
+        assertEquals(ImmutableSet.of("testChild"),
+                lookupChild.find("foo", "xyz"));
+        assertEquals(ImmutableSet.of(), lookupChild.find("foo", "abc"));
+
+    }
+
+    /**
+     * Reindex Test
+     * <ul>
+     * <li>Add some content</li>
+     * <li>Add an index definition with the reindex flag set</li>
+     * <li>Search & verify</li>
+     * </ul>
+     */
+    @Test
+    public void testReindex() throws Exception {
+        NodeState root = MemoryNodeState.EMPTY_NODE;
+
+        NodeBuilder builder = root.builder();
+
+        builder.child("testRoot").setProperty("foo", "abc");
+        NodeState before = builder.getNodeState();
+
         builder.child("oak:index")
-                .child("foo")
+                .child("rootIndex")
+                .setProperty("propertyNames", "foo")
+                .setProperty("type", "property")
+                .setProperty(REINDEX_PROPERTY_NAME, true)
                 .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE,
                         Type.NAME);
-        builder.child("test")
-                .child("other")
-                .child("oak:index")
-                .child("index2")
+        NodeState after = builder.getNodeState();
+
+        IndexHookManager im = new IndexHookManager(
+                new CompositeIndexHookProvider(new PropertyIndexHookProvider()));
+        NodeState indexed = im.processCommit(before, after);
+
+        // first check that the index content nodes exist
+        NodeState ns = checkPathExists(indexed, "oak:index", "rootIndex");
+        checkPathExists(ns, ":index");
+        PropertyState ps = ns.getProperty(REINDEX_PROPERTY_NAME);
+        assertNotNull(ps);
+        assertFalse(ps.getValue(Type.BOOLEAN).booleanValue());
+
+        // next, lookup
+        PropertyIndexLookup lookup = new PropertyIndexLookup(indexed);
+        assertEquals(ImmutableSet.of("testRoot"), lookup.find("foo", "abc"));
+    }
+
+    /**
+     * Reindex Test
+     * <ul>
+     * <li>Add some content</li>
+     * <li>Add an index definition with no reindex flag</li>
+     * <li>Search & verify</li>
+     * </ul>
+     */
+    @Test
+    public void testReindex2() throws Exception {
+        NodeState root = MemoryNodeState.EMPTY_NODE;
+
+        NodeBuilder builder = root.builder();
+
+        builder.child("testRoot").setProperty("foo", "abc");
+        NodeState before = builder.getNodeState();
+
+        builder.child("oak:index")
+                .child("rootIndex")
+                .setProperty("propertyNames", "foo")
+                .setProperty("type", "property")
                 .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE,
                         Type.NAME);
         NodeState after = builder.getNodeState();
 
-        // <path>, <state>
-        Map<String, NodeBuilder> defs = new HashMap<String, NodeBuilder>();
-        IndexDefDiff diff = new IndexDefDiff(builder, defs);
-        after.compareAgainstBaseState(before, diff);
-
-        List<String> reindex = Lists.newArrayList("/oak:index/foo",
-                "/test/other/oak:index/index2");
-        List<String> updates = Lists.newArrayList("/oak:index/existing");
-
-        Iterator<String> iterator = defs.keySet().iterator();
-        while (iterator.hasNext()) {
-            String path = iterator.next();
-            if (IndexHookManager.getAndResetReindex(defs.get(path))) {
-                assertTrue("Missing " + path + " from reindex list",
-                        reindex.remove(path));
-            } else {
-                assertTrue("Missing " + path + " from updates list",
-                        updates.remove(path));
-            }
-            iterator.remove();
-        }
-        assertTrue(reindex.isEmpty());
-        assertTrue(updates.isEmpty());
-        assertTrue(defs.isEmpty());
+        IndexHookManager im = new IndexHookManager(
+                new CompositeIndexHookProvider(new PropertyIndexHookProvider()));
+        NodeState indexed = im.processCommit(before, after);
+
+        // first check that the index content nodes exist
+        NodeState ns = checkPathExists(indexed, "oak:index", "rootIndex");
+        checkPathExists(ns, ":index");
+        PropertyState ps = ns.getProperty(REINDEX_PROPERTY_NAME);
+        assertNotNull(ps);
+        assertFalse(ps.getValue(Type.BOOLEAN).booleanValue());
+
+        // next, lookup
+        PropertyIndexLookup lookup = new PropertyIndexLookup(indexed);
+        assertEquals(ImmutableSet.of("testRoot"), lookup.find("foo", "abc"));
     }
 
+    /**
+     * Reindex Test
+     * <ul>
+     * <li>Add some content & an index definition</li>
+     * <li>Update the index def by setting the reindex flag to true</li>
+     * <li>Search & verify</li>
+     * </ul>
+     */
     @Test
-    public void testReindexFlag() throws Exception {
+    public void testReindex3() throws Exception {
         NodeState root = MemoryNodeState.EMPTY_NODE;
 
         NodeBuilder builder = root.builder();
+
+        builder.child("testRoot").setProperty("foo", "abc");
         builder.child("oak:index")
-                .child("reindexed")
+                .child("rootIndex")
+                .setProperty("propertyNames", "foo")
+                .setProperty("type", "property")
                 .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE,
-                        Type.NAME)
-                .setProperty(IndexConstants.REINDEX_PROPERTY_NAME, true);
-        NodeState state = builder.getNodeState();
-
-        // <path>, <state>
-        Map<String, NodeBuilder> defs = new HashMap<String, NodeBuilder>();
-        IndexDefDiff diff = new IndexDefDiff(builder, defs);
-        state.compareAgainstBaseState(state, diff);
-
-        List<String> reindex = Lists.newArrayList("/oak:index/reindexed");
-        Iterator<String> iterator = defs.keySet().iterator();
-        while (iterator.hasNext()) {
-            String path = iterator.next();
-            assertTrue("Missing " + path + " from reindex list",
-                    reindex.remove(path));
-            iterator.remove();
+                        Type.NAME);
+        NodeState before = builder.getNodeState();
+        builder.child("oak:index").child("rootIndex")
+                .setProperty(REINDEX_PROPERTY_NAME, true);
+        NodeState after = builder.getNodeState();
+
+        IndexHookManager im = new IndexHookManager(
+                new CompositeIndexHookProvider(new PropertyIndexHookProvider()));
+        NodeState indexed = im.processCommit(before, after);
+
+        // first check that the index content nodes exist
+        NodeState ns = checkPathExists(indexed, "oak:index", "rootIndex");
+        checkPathExists(ns, ":index");
+        PropertyState ps = ns.getProperty(REINDEX_PROPERTY_NAME);
+        assertNotNull(ps);
+        assertFalse(ps.getValue(Type.BOOLEAN).booleanValue());
+
+        // next, lookup
+        PropertyIndexLookup lookup = new PropertyIndexLookup(indexed);
+        assertEquals(ImmutableSet.of("testRoot"), lookup.find("foo", "abc"));
+    }
+
+    private static NodeState checkPathExists(NodeState state, String... verify) {
+        NodeState c = state;
+        for (String p : verify) {
+            assertTrue(c.hasChildNode(p));
+            c = c.getChildNode(p);
         }
-        assertTrue(reindex.isEmpty());
-        assertTrue(defs.isEmpty());
+        return c;
     }
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java?rev=1407425&r1=1407424&r2=1407425&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
Fri Nov  9 11:26:30 2012
@@ -16,12 +16,19 @@
  */
 package org.apache.jackrabbit.oak.plugins.index.lucene;
 
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Iterator;
+
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.plugins.index.IndexHookManager;
 import org.apache.jackrabbit.oak.plugins.nodetype.InitialContent;
 import org.apache.jackrabbit.oak.query.AbstractQueryTest;
+import org.apache.jackrabbit.oak.query.JsopUtil;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -46,7 +53,7 @@ public class LuceneIndexQueryTest extend
             .with(new IndexHookManager(new LuceneIndexHookProvider()))
             .createContentRepository();
     }
-    
+
     @Test
     @Ignore("OAK-420")
     public void sql2() throws Exception {
@@ -59,5 +66,54 @@ public class LuceneIndexQueryTest extend
         test("sql2_measure.txt");
     }
 
+    @Test
+    public void descendantTest() throws Exception {
+        JsopUtil.apply(root, "/ + \"test\": { \"a\": {}, \"b\": {} }");
+        root.commit();
 
+        Iterator<String> result = executeQuery(
+                "select * from [nt:base] where isdescendantnode('/test')",
+                "JCR-SQL2").iterator();
+        assertTrue(result.hasNext());
+        assertEquals("/test/a", result.next());
+        assertEquals("/test/b", result.next());
+        assertFalse(result.hasNext());
+    }
+
+    @Test
+    public void descendantTest2() throws Exception {
+        JsopUtil.apply(
+                root,
+                "/ + \"test\": { \"a\": { \"name\": [\"Hello\", \"World\" ] }, \"b\": { \"name\"
: \"Hello\" }}");
+        root.commit();
+
+        Iterator<String> result = executeQuery(
+                "select * from [nt:base] where isdescendantnode('/test') and name='World'",
+                "JCR-SQL2").iterator();
+        assertTrue(result.hasNext());
+        assertEquals("/test/a", result.next());
+        assertFalse(result.hasNext());
+    }
+
+    @Test
+    @Ignore("OAK-420")
+    public void ischildnodeTest() throws Exception {
+        JsopUtil.apply(
+                root,
+                "/ + \"parents\": { \"p0\": {\"id\": \"0\"}, \"p1\": {\"id\": \"1\"}, \"p2\":
{\"id\": \"2\"}}");
+        JsopUtil.apply(
+                root,
+                "/ + \"children\": { \"c1\": {\"p\": \"1\"}, \"c2\": {\"p\": \"1\"}, \"c3\":
{\"p\": \"2\"}, \"c4\": {\"p\": \"3\"}}");
+        root.commit();
+
+        Iterator<String> result = executeQuery(
+                "select * from [nt:base] as p inner join [nt:base] as p2 on ischildnode(p2,
p) where p.[jcr:path] = '/'",
+                "JCR-SQL2").iterator();
+        assertTrue(result.hasNext());
+        assertEquals("/, /children", result.next());
+        assertEquals("/, /jcr:system", result.next());
+        assertEquals("/, /oak:index", result.next());
+        assertEquals("/, /parents", result.next());
+        assertFalse(result.hasNext());
+    }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java?rev=1407425&r1=1407424&r2=1407425&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java
Fri Nov  9 11:26:30 2012
@@ -50,9 +50,9 @@ public class LuceneIndexTest implements 
         builder.setProperty("foo", "bar");
         NodeState after = builder.getNodeState();
 
-        IndexHook l = new LuceneHook(builder);
-        after.compareAgainstBaseState(before, l.preProcess());
-        l.postProcess();
+        IndexHook l = new LuceneIndexDiff(builder);
+        after.compareAgainstBaseState(before, l);
+        l.apply();
         l.close();
 
         IndexDefinition testDef = new IndexDefinitionImpl("lucene",

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java?rev=1407425&r1=1407424&r2=1407425&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
Fri Nov  9 11:26:30 2012
@@ -40,6 +40,7 @@ public class PropertyIndexTest {
         NodeBuilder builder = root.builder();
         builder.child("oak:index").child("foo")
                 .setProperty("jcr:primaryType", "oak:queryIndexDefinition", Type.NAME)
+                .setProperty("type", "property")
                 .setProperty("propertyNames", "foo");
         NodeState before = builder.getNodeState();
 
@@ -63,9 +64,9 @@ public class PropertyIndexTest {
         withoutIndex = System.nanoTime() - withoutIndex;
 
         // ... then see how adding an index affects the code
-        IndexHook p = new PropertyIndexHook(builder);
-        after.compareAgainstBaseState(before, p.preProcess());
-        p.postProcess();
+        IndexHook p = new PropertyIndexDiff(builder);
+        after.compareAgainstBaseState(before, p);
+        p.apply();
         p.close();
 
         lookup = new PropertyIndexLookup(builder.getNodeState());
@@ -88,6 +89,7 @@ public class PropertyIndexTest {
         NodeBuilder builder = root.builder();
         builder.child("oak:index").child("fooIndex")
                 .setProperty("jcr:primaryType", "oak:queryIndexDefinition", Type.NAME)
+                .setProperty("type", "property")
                 .setProperty("propertyNames", Arrays.asList("foo", "extrafoo"), Type.STRINGS);
         NodeState before = builder.getNodeState();
 
@@ -113,9 +115,9 @@ public class PropertyIndexTest {
         withoutIndex = System.nanoTime() - withoutIndex;
 
         // ... then see how adding an index affects the code
-        IndexHook p = new PropertyIndexHook(builder);
-        after.compareAgainstBaseState(before, p.preProcess());
-        p.postProcess();
+        IndexHook p = new PropertyIndexDiff(builder);
+        after.compareAgainstBaseState(before, p);
+        p.apply();
         p.close();
 
         lookup = new PropertyIndexLookup(builder.getNodeState());



Mime
View raw message