jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1475767 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/memory/MutableNodeState.java test/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilderTest.java
Date Thu, 25 Apr 2013 13:47:16 GMT
Author: mduerig
Date: Thu Apr 25 13:46:24 2013
New Revision: 1475767

URL: http://svn.apache.org/r1475767
Log:
OAK-781: Clarify / fix effects of MISSING_NODE as base state of NodeBuilder
isConnected should ignore non existing child nodes

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

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MutableNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MutableNodeState.java?rev=1475767&r1=1475766&r2=1475767&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MutableNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MutableNodeState.java
Thu Apr 25 13:46:24 2013
@@ -211,7 +211,8 @@ class MutableNodeState extends AbstractN
     boolean isConnected(String name) {
         assert base != null;
 
-        return nodes.get(name) != null ||
+        MutableNodeState node = nodes.get(name);
+        return node != null && node.exists() ||
                 !nodes.containsKey(name) && base.getChildNode(name).exists();
     }
 

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=1475767&r1=1475766&r2=1475767&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
Thu Apr 25 13:46:24 2013
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.oak.spi.sta
 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 {
@@ -260,6 +261,18 @@ public class MemoryNodeBuilderTest {
         NodeBuilder rootBuilder = base.builder();
         NodeBuilder any = rootBuilder.getChildNode("any");
         assertFalse(any.isConnected());
+        try {
+            any.getChildNode("any");
+            fail();
+        } catch (IllegalStateException expected) {}
+        try {
+            any.exists();
+            fail();
+        } catch (IllegalStateException expected) {}
+        try {
+            any.setChildNode("any");
+            fail();
+        } catch (IllegalStateException expected) {}
     }
 
     @Test
@@ -335,6 +348,7 @@ public class MemoryNodeBuilderTest {
     }
 
     @Test
+    @Ignore("OAK-781")
     public void modifyChildNodeOfNonExistingNode() {
         NodeBuilder rootBuilder = EMPTY_NODE.builder();
 
@@ -433,6 +447,45 @@ public class MemoryNodeBuilderTest {
         assertTrue(c.hasProperty("c2"));
     }
 
+    @Test
+    @Ignore("OAK-781")
+    public void navigateNonExistingNode() {
+        NodeBuilder rootBuilder = EMPTY_NODE.builder();
+
+        // +"/a":{"b":{"c":{"c":"cValue"}}} where b.exists() == false
+        rootBuilder.child("a").setChildNode("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());
+        assertTrue(c.hasProperty("c"));
+
+        NodeBuilder aBuilder = rootBuilder.getChildNode("a");
+        NodeBuilder bBuilder = aBuilder.getChildNode("b");
+        NodeBuilder cBuilder = bBuilder.getChildNode("c");
+
+        assertTrue(aBuilder.exists());
+        assertFalse(bBuilder.isConnected());
+        assertTrue(cBuilder.exists());
+
+        cBuilder.setProperty("c2", "c2Value");
+        r = rootBuilder.getNodeState();
+        a = r.getChildNode("a");
+        b = a.getChildNode("b");
+        c = b.getChildNode("c");
+
+        assertTrue(a.exists());
+        assertFalse(b.exists());
+        assertTrue(c.exists());
+        assertTrue(c.hasProperty("c"));
+        assertTrue(c.hasProperty("c2"));
+    }
+
     private static NodeState createBC(final boolean exists) {
         final NodeState C = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE)
             .setProperty("c", "cValue")



Mime
View raw message