jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1476086 - in /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index: IndexUpdateTest.java p2/ property/PropertyIndexTest.java property/RelativePathTest.java
Date Fri, 26 Apr 2013 07:30:29 GMT
Author: alexparvulescu
Date: Fri Apr 26 07:30:29 2013
New Revision: 1476086

URL: http://svn.apache.org/r1476086
Log:
OAK-734 Refactor indexing code to use Editors - rename index type to 'property'

Removed:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/
Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java?rev=1476086&r1=1476085&r2=1476086&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
Fri Apr 26 07:30:29 2013
@@ -18,6 +18,8 @@ package org.apache.jackrabbit.oak.plugin
 
 import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
 import static org.apache.jackrabbit.JcrConstants.NT_BASE;
+import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_CONTENT_NODE_NAME;
+import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME;
 import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefinition;
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
@@ -63,11 +65,12 @@ public class IndexUpdateTest {
      */
     @Test
     public void test() throws Exception {
-        createIndexDefinition(builder.child("oak:index"), "rootIndex", true,
-                false, ImmutableSet.of("foo"), null);
+        createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
+                "rootIndex", true, false, ImmutableSet.of("foo"), null);
         createIndexDefinition(
-                builder.child("newchild").child("other").child("oak:index"),
-                "subIndex", true, false, ImmutableSet.of("foo"), null);
+                builder.child("newchild").child("other")
+                        .child(INDEX_DEFINITIONS_NAME), "subIndex", true,
+                false, ImmutableSet.of("foo"), null);
 
         NodeState before = builder.getNodeState();
 
@@ -84,9 +87,10 @@ public class IndexUpdateTest {
         NodeState indexed = hook.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");
+        checkPathExists(indexed, INDEX_DEFINITIONS_NAME, "rootIndex",
+                INDEX_CONTENT_NODE_NAME);
+        checkPathExists(indexed, "newchild", "other", INDEX_DEFINITIONS_NAME,
+                "subIndex", INDEX_CONTENT_NODE_NAME);
 
         PropertyIndexLookup lookup = new PropertyIndexLookup(indexed);
         assertEquals(ImmutableSet.of("testRoot"), find(lookup, "foo", "abc"));
@@ -111,8 +115,8 @@ public class IndexUpdateTest {
     public void testReindex() throws Exception {
         builder.child("testRoot").setProperty("foo", "abc");
         NodeState before = builder.getNodeState();
-        createIndexDefinition(builder.child("oak:index"), "rootIndex", true,
-                false, ImmutableSet.of("foo"), null);
+        createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
+                "rootIndex", true, false, ImmutableSet.of("foo"), null);
 
         NodeState after = builder.getNodeState();
 
@@ -122,8 +126,9 @@ public class IndexUpdateTest {
         NodeState indexed = hook.processCommit(before, after);
 
         // first check that the index content nodes exist
-        NodeState ns = checkPathExists(indexed, "oak:index", "rootIndex");
-        checkPathExists(ns, ":index");
+        NodeState ns = checkPathExists(indexed, INDEX_DEFINITIONS_NAME,
+                "rootIndex");
+        checkPathExists(ns, INDEX_CONTENT_NODE_NAME);
         PropertyState ps = ns.getProperty(REINDEX_PROPERTY_NAME);
         assertNotNull(ps);
         assertFalse(ps.getValue(Type.BOOLEAN));
@@ -145,11 +150,12 @@ public class IndexUpdateTest {
     public void testReindex2() throws Exception {
         builder.child("testRoot").setProperty("foo", "abc");
 
-        createIndexDefinition(builder.child("oak:index"), "rootIndex", true,
-                false, ImmutableSet.of("foo"), null).removeProperty("reindex");
+        createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
+                "rootIndex", true, false, ImmutableSet.of("foo"), null)
+                .removeProperty("reindex");
 
         NodeState before = builder.getNodeState();
-        builder.child("oak:index").child("rootIndex")
+        builder.child(INDEX_DEFINITIONS_NAME).child("rootIndex")
                 .setProperty(REINDEX_PROPERTY_NAME, true);
         NodeState after = builder.getNodeState();
 
@@ -159,8 +165,9 @@ public class IndexUpdateTest {
         NodeState indexed = hook.processCommit(before, after);
 
         // first check that the index content nodes exist
-        NodeState ns = checkPathExists(indexed, "oak:index", "rootIndex");
-        checkPathExists(ns, ":index");
+        NodeState ns = checkPathExists(indexed, INDEX_DEFINITIONS_NAME,
+                "rootIndex");
+        checkPathExists(ns, INDEX_CONTENT_NODE_NAME);
         PropertyState ps = ns.getProperty(REINDEX_PROPERTY_NAME);
         assertNotNull(ps);
         assertFalse(ps.getValue(Type.BOOLEAN));
@@ -172,16 +179,17 @@ public class IndexUpdateTest {
 
     @Test
     public void testIndexDefinitions() throws Exception {
-        createIndexDefinition(builder.child("oak:index"), "existing", true,
-                false, ImmutableSet.of("foo"), null);
+        createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
+                "existing", true, false, ImmutableSet.of("foo"), null);
 
         NodeState before = builder.getNodeState();
         // Add index definition
-        createIndexDefinition(builder.child("oak:index"), "foo", true, false,
-                ImmutableSet.of("foo"), null);
+        createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo",
+                true, false, ImmutableSet.of("foo"), null);
         createIndexDefinition(
-                builder.child("test").child("other").child("oak:index"),
-                "index2", true, false, ImmutableSet.of("foo"), null);
+                builder.child("test").child("other")
+                        .child(INDEX_DEFINITIONS_NAME), "index2", true, false,
+                ImmutableSet.of("foo"), null);
         NodeState after = builder.getNodeState();
 
         IndexUpdateProvider p = new IndexUpdateProvider(
@@ -190,9 +198,10 @@ public class IndexUpdateTest {
         NodeState indexed = hook.processCommit(before, after);
 
         // check that the index content nodes exist
-        checkPathExists(indexed, "oak:index", "existing", ":index");
-        checkPathExists(indexed, "test", "other", "oak:index", "index2",
-                ":index");
+        checkPathExists(indexed, INDEX_DEFINITIONS_NAME, "existing",
+                INDEX_CONTENT_NODE_NAME);
+        checkPathExists(indexed, "test", "other", INDEX_DEFINITIONS_NAME,
+                "index2", INDEX_CONTENT_NODE_NAME);
     }
 
     private Set<String> find(PropertyIndexLookup lookup, String name,

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=1476086&r1=1476085&r2=1476086&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 Apr 26 07:30:29 2013
@@ -18,8 +18,13 @@ package org.apache.jackrabbit.oak.plugin
 
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertNull;
+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.JcrConstants.NT_FILE;
+import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
+import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
+import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.createIndexDefinition;
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_NODE_TYPES;
 import static org.junit.Assert.assertEquals;
@@ -31,8 +36,6 @@ import java.util.Set;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditor;
-import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexLookup;
 import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
 import org.apache.jackrabbit.oak.query.ast.SelectorImpl;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
@@ -59,11 +62,8 @@ public class PropertyIndexTest {
 
         // Add index definition
         NodeBuilder builder = root.builder();
-        builder.child("oak:index")
-                .child("foo")
-                .setProperty("jcr:primaryType", "oak:queryIndexDefinition",
-                        Type.NAME).setProperty("type", "p2")
-                .setProperty("propertyNames", Arrays.asList("foo"), Type.NAMES);
+        createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo",
+                true, false, ImmutableSet.of("foo"), null);
         NodeState before = builder.getNodeState();
 
         // Add some content and process it through the property index hook
@@ -109,13 +109,9 @@ public class PropertyIndexTest {
 
         // Add index definition
         NodeBuilder builder = root.builder();
-        builder.child("oak:index")
-                .child("fooIndex")
-                .setProperty("jcr:primaryType", "oak:queryIndexDefinition",
-                        Type.NAME)
-                .setProperty("type", "p2")
-                .setProperty("propertyNames", Arrays.asList("foo", "extrafoo"),
-                        Type.NAMES);
+        createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
+                "fooIndex", true, false, ImmutableSet.of("foo", "extrafoo"),
+                null);
         NodeState before = builder.getNodeState();
 
         // Add some content and process it through the property index hook
@@ -163,39 +159,28 @@ public class PropertyIndexTest {
 
         // Add index definitions
         NodeBuilder builder = root.builder();
-        NodeBuilder index = builder.child("oak:index");
-        index.child("fooIndex")
-                .setProperty("jcr:primaryType", "oak:queryIndexDefinition",
-                        Type.NAME)
-                .setProperty("type", "p2")
-                .setProperty("propertyNames", Arrays.asList("foo", "extrafoo"),
-                        Type.NAMES)
-                .setProperty("declaringNodeTypes",
-                        Arrays.asList("nt:unstructured"), Type.NAMES);
-        index.child("fooIndexFile")
-                .setProperty("jcr:primaryType", "oak:queryIndexDefinition",
-                        Type.NAME)
-                .setProperty("type", "p2")
-                .setProperty("propertyNames", Arrays.asList("foo"),
-                        Type.NAMES)
-                .setProperty("declaringNodeTypes", Arrays.asList("nt:file"),
-                        Type.NAMES);
+        NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
+        createIndexDefinition(index, "fooIndex", true, false,
+                ImmutableSet.of("foo", "extrafoo"),
+                ImmutableSet.of(NT_UNSTRUCTURED));
+        createIndexDefinition(index, "fooIndexFile", true, false,
+                ImmutableSet.of("foo"), ImmutableSet.of(NT_FILE));
         NodeState before = builder.getNodeState();
 
         // Add some content and process it through the property index hook
         builder = before.builder();
         builder.child("a")
-                .setProperty("jcr:primaryType", "nt:unstructured", Type.NAME)
+                .setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, Type.NAME)
                 .setProperty("foo", "abc");
         builder.child("b")
-                .setProperty("jcr:primaryType", "nt:unstructured", Type.NAME)
+                .setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, Type.NAME)
                 .setProperty("foo", Arrays.asList("abc", "def"), Type.STRINGS);
         NodeState after = builder.getNodeState();
 
         EditorDiff.process(new PropertyIndexEditor(builder), before, after);
         NodeState indexed = builder.getNodeState();
 
-        FilterImpl f = createFilter(indexed, "nt:unstructured");
+        FilterImpl f = createFilter(indexed, NT_UNSTRUCTURED);
 
         // Query the index
         PropertyIndexLookup lookup = new PropertyIndexLookup(indexed);
@@ -230,38 +215,28 @@ public class PropertyIndexTest {
 
         // Add index definitions
         NodeBuilder builder = root.builder();
-        NodeBuilder index = builder.child("oak:index");
-        index.child("fooIndex")
-                .setProperty("jcr:primaryType", "oak:queryIndexDefinition",
-                        Type.NAME)
-                .setProperty("type", "p2")
-                .setProperty("propertyNames", Arrays.asList("foo", "extrafoo"),
-                        Type.NAMES);
-        index.child("fooIndexFile")
-                .setProperty("jcr:primaryType", "oak:queryIndexDefinition",
-                        Type.NAME)
-                .setProperty("type", "p2")
-                .setProperty("propertyNames", Arrays.asList("foo"),
-                        Type.NAMES)
-                .setProperty("declaringNodeTypes", Arrays.asList("nt:file"),
-                        Type.NAMES);
+        NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
+        createIndexDefinition(index, "fooIndex", true, false,
+                ImmutableSet.of("foo", "extrafoo"), null);
+        createIndexDefinition(index, "fooIndexFile", true, false,
+                ImmutableSet.of("foo"), ImmutableSet.of(NT_FILE));
         NodeState before = builder.getNodeState();
 
         // Add some content and process it through the property index hook
         builder = before.builder();
         builder.child("a")
-            .setProperty("jcr:primaryType", "nt:unstructured", Type.NAME)
-            .setProperty("foo", "abc");
+                .setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, Type.NAME)
+                .setProperty("foo", "abc");
         builder.child("b")
-            .setProperty("jcr:primaryType", "nt:unstructured", Type.NAME)
-            .setProperty("foo", Arrays.asList("abc", "def"), Type.STRINGS);
+                .setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, Type.NAME)
+                .setProperty("foo", Arrays.asList("abc", "def"), Type.STRINGS);
         NodeState after = builder.getNodeState();
 
         // Add an index
         EditorDiff.process(new PropertyIndexEditor(builder), before, after);
         NodeState indexed = builder.getNodeState();
 
-        FilterImpl f = createFilter(after, "nt:unstructured");
+        FilterImpl f = createFilter(after, NT_UNSTRUCTURED);
 
         // Query the index
         PropertyIndexLookup lookup = new PropertyIndexLookup(indexed);
@@ -283,15 +258,8 @@ public class PropertyIndexTest {
 
         // Add index definition
         NodeBuilder builder = root.builder();
-        builder.child("oak:index")
-                .child("fooIndex")
-                .setProperty("jcr:primaryType", "oak:queryIndexDefinition",
-                        Type.NAME)
-                .setProperty("type", "p2")
-                .setProperty("unique", "true")
-                .setProperty("propertyNames", Arrays.asList("foo"),
-                        Type.NAMES);
-
+        createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
+                "fooIndex", true, true, ImmutableSet.of("foo"), null);
         NodeState before = builder.getNodeState();
         builder = before.builder();
         builder.child("a").setProperty("foo", "abc");
@@ -299,8 +267,8 @@ public class PropertyIndexTest {
                 Type.STRINGS);
         NodeState after = builder.getNodeState();
 
-        CommitFailedException expected =
-                EditorDiff.process(new PropertyIndexEditor(builder), before, after);
+        CommitFailedException expected = EditorDiff.process(
+                new PropertyIndexEditor(builder), before, after);
         assertNotNull("Unique constraint should be respected", expected);
     }
 
@@ -310,21 +278,14 @@ public class PropertyIndexTest {
 
         // Add index definition
         NodeBuilder builder = root.builder();
-        builder.child("oak:index")
-                .child("fooIndex")
-                .setProperty("jcr:primaryType", "oak:queryIndexDefinition",
-                        Type.NAME)
-                .setProperty("type", "p2")
-                .setProperty("unique", "true")
-                .setProperty("propertyNames", Arrays.asList("foo"),
-                        Type.NAMES)
-                .setProperty(PropertyIndexEditor.declaringNodeTypes,
-                        Arrays.asList("typeFoo"), Type.NAMES);
+        createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
+                "fooIndex", true, true, ImmutableSet.of("foo"),
+                ImmutableSet.of("typeFoo"));
         NodeState before = builder.getNodeState();
         builder = before.builder();
-        builder.child("a").setProperty("jcr:primaryType", "typeFoo", Type.NAME)
+        builder.child("a").setProperty(JCR_PRIMARYTYPE, "typeFoo", Type.NAME)
                 .setProperty("foo", "abc");
-        builder.child("b").setProperty("jcr:primaryType", "typeBar", Type.NAME)
+        builder.child("b").setProperty(JCR_PRIMARYTYPE, "typeBar", Type.NAME)
                 .setProperty("foo", "abc");
         NodeState after = builder.getNodeState();
 
@@ -339,21 +300,14 @@ public class PropertyIndexTest {
 
         // Add index definition
         NodeBuilder builder = root.builder();
-        builder.child("oak:index")
-                .child("fooIndex")
-                .setProperty("jcr:primaryType", "oak:queryIndexDefinition",
-                        Type.NAME)
-                .setProperty("type", "p2")
-                .setProperty("unique", "true")
-                .setProperty("propertyNames", Arrays.asList("foo"),
-                        Type.NAMES)
-                .setProperty(PropertyIndexEditor.declaringNodeTypes,
-                        Arrays.asList("typeFoo"), Type.NAMES);
+        createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
+                "fooIndex", true, true, ImmutableSet.of("foo"),
+                ImmutableSet.of("typeFoo"));
         NodeState before = builder.getNodeState();
         builder = before.builder();
-        builder.child("a").setProperty("jcr:primaryType", "typeFoo", Type.NAME)
+        builder.child("a").setProperty(JCR_PRIMARYTYPE, "typeFoo", Type.NAME)
                 .setProperty("foo", "abc");
-        builder.child("b").setProperty("jcr:primaryType", "typeFoo", Type.NAME)
+        builder.child("b").setProperty(JCR_PRIMARYTYPE, "typeFoo", Type.NAME)
                 .setProperty("foo", "abc");
         NodeState after = builder.getNodeState();
 
@@ -368,19 +322,12 @@ public class PropertyIndexTest {
 
         // Add index definition
         NodeBuilder builder = root.builder();
-        builder.child("oak:index")
-                .child("fooIndex")
-                .setProperty("jcr:primaryType", "oak:queryIndexDefinition",
-                        Type.NAME)
-                .setProperty("type", "p2")
-                .setProperty("unique", "true")
-                .setProperty("propertyNames", Arrays.asList("foo"),
-                        Type.NAMES)
-                .setProperty(PropertyIndexEditor.declaringNodeTypes,
-                        Arrays.asList("typeFoo"), Type.NAMES);
-        builder.child("a").setProperty("jcr:primaryType", "typeFoo", Type.NAME)
+        createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
+                "fooIndex", true, true, ImmutableSet.of("foo"),
+                ImmutableSet.of("typeFoo"));
+        builder.child("a").setProperty(JCR_PRIMARYTYPE, "typeFoo", Type.NAME)
                 .setProperty("foo", "abc");
-        builder.child("b").setProperty("jcr:primaryType", "typeBar", Type.NAME)
+        builder.child("b").setProperty(JCR_PRIMARYTYPE, "typeBar", Type.NAME)
                 .setProperty("foo", "abc");
         NodeState before = builder.getNodeState();
         builder = before.builder();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java?rev=1476086&r1=1476085&r2=1476086&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/RelativePathTest.java
Fri Apr 26 07:30:29 2013
@@ -82,8 +82,8 @@ public class RelativePathTest extends Ab
                 "explain select [jcr:path] from [nt:base] where [n/myProp] is not null",
                 Query.JCR_SQL2);
         assertEquals(1, lines.size());
-        // make sure it used the p2 index
-        assertTrue(lines.get(0).contains("p2 myProp"));
+        // make sure it used the property index
+        assertTrue(lines.get(0).contains("property myProp"));
 
         paths = executeQuery(
                 "select [jcr:path] from [nt:base] where [n/myProp] = 'foo'",



Mime
View raw message