jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1443498 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java
Date Thu, 07 Feb 2013 14:17:27 GMT
Author: alexparvulescu
Date: Thu Feb  7 14:17:27 2013
New Revision: 1443498

URL: http://svn.apache.org/viewvc?rev=1443498&view=rev
Log:
OAK-613 NPE in Property2IndexDiff#getIndexes(String) when processing a removed node.
 - Test for the NPE guard

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java?rev=1443498&r1=1443497&r2=1443498&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/p2/Property2IndexTest.java
Thu Feb  7 14:17:27 2013
@@ -84,7 +84,7 @@ public class Property2IndexTest {
         cost = lookup.getCost("foo", null);
         assertTrue("cost: " + cost, cost >= MANY);
     }
-    
+
     private static Set<String> find(Property2IndexLookup lookup, String name, String
value) {
         return Sets.newHashSet(lookup.query(null, name, value == null ? null : PropertyValues.newString(value)));
     }
@@ -232,4 +232,34 @@ public class Property2IndexTest {
         }
     }
 
+    @Test
+    public void testUniqueByTypeDelete() throws Exception {
+
+        NodeState root = MemoryNodeState.EMPTY_NODE;
+
+        // 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.STRINGS)
+                .setProperty(Property2IndexDiff.declaringNodeTypes, Arrays.asList("typeFoo"),
Type.STRINGS);
+        builder.child("a")
+                .setProperty("jcr:primaryType", "typeFoo", Type.NAME)
+                .setProperty("foo", "abc");
+        builder.child("b")
+                .setProperty("jcr:primaryType", "typeBar", Type.NAME)
+                .setProperty("foo", "abc");
+        NodeState before = builder.getNodeState();
+        builder = before.builder();
+        builder.removeNode("b");
+        NodeState after = builder.getNodeState();
+
+        IndexHook p = new Property2IndexDiff(builder);
+        after.compareAgainstBaseState(before, p);
+        p.apply();
+        p.close();
+    }
+
 }



Mime
View raw message