You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2013/04/17 14:13:03 UTC

svn commit: r1468861 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java

Author: mduerig
Date: Wed Apr 17 12:13:02 2013
New Revision: 1468861

URL: http://svn.apache.org/r1468861
Log:
OAK-781: Clarify / fix effects of MISSING_NODE as base state of NodeBuilder
(@Ignored) test case demonstrating failing assertion when an intermediate node of a builder hierarchy is based on a node existing node state

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java?rev=1468861&r1=1468860&r2=1468861&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java Wed Apr 17 12:13:02 2013
@@ -16,20 +16,25 @@
  */
 package org.apache.jackrabbit.oak.plugins.memory;
 
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.junit.Before;
-import org.junit.Test;
-
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
 import static junit.framework.Assert.assertTrue;
 import static junit.framework.Assert.fail;
 import static org.apache.jackrabbit.oak.api.Type.STRING;
 import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 
+import javax.annotation.Nonnull;
+
+import com.google.common.collect.ImmutableSet;
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.spi.state.AbstractNodeState;
+import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
 public class MemoryNodeBuilderTest {
 
     private NodeState base;
@@ -192,4 +197,59 @@ public class MemoryNodeBuilderTest {
         n.hasChildNode("any");
     }
 
+    @Test
+    @Ignore
+    public void assertion_OAK781() {
+        MemoryNodeBuilder rootBuilder = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE);
+        rootBuilder.child("a").setNode("b", createBC(false));
+
+        NodeState r = rootBuilder.getNodeState();
+        NodeState a = r.getChildNode("a");
+        NodeState b = a.getChildNode("b");
+        NodeState c = b.getChildNode("c");
+
+        assertTrue(a.exists());
+        assertFalse(b.exists());
+        assertTrue(c.exists());
+
+        rootBuilder.child("a").child("b").child("c");
+    }
+
+    private static NodeState createBC(final boolean exists) {
+        return new AbstractNodeState() {
+            @Override
+            public boolean exists() {
+                return exists;
+            }
+
+            @Nonnull
+            @Override
+            public Iterable<? extends PropertyState> getProperties() {
+                return ImmutableSet.of();
+            }
+
+            @Nonnull
+            @Override
+            public NodeState getChildNode(@Nonnull String name) {
+                if ("c".equals(name)) {
+                    return EmptyNodeState.EMPTY_NODE;
+                } else {
+                    return EmptyNodeState.MISSING_NODE;
+                }
+            }
+
+            @Nonnull
+            @Override
+            public Iterable<? extends ChildNodeEntry> getChildNodeEntries() {
+                return ImmutableSet.of();
+            }
+
+            @Nonnull
+            @Override
+            public NodeBuilder builder() {
+                return new MemoryNodeBuilder(this);
+            }
+        };
+    }
+
 }