jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1309484 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/kernel/TransientNodeState.java test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java
Date Wed, 04 Apr 2012 16:33:01 GMT
Author: mduerig
Date: Wed Apr  4 16:33:00 2012
New Revision: 1309484

URL: http://svn.apache.org/viewvc?rev=1309484&view=rev
Log:
OAK-9: Internal tree builder
fix copy constructor
add deep copy test
add tests for child node count and property count

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientNodeState.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientNodeState.java?rev=1309484&r1=1309483&r2=1309484&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/TransientNodeState.java
Wed Apr  4 16:33:00 2012
@@ -132,14 +132,14 @@ public class TransientNodeState {
         this.name = name;
 
         // recursively copy all existing node states
-        for (Entry<String, TransientNodeState> existing : existingChildNodes.entrySet())
{
+        for (Entry<String, TransientNodeState> existing : state.existingChildNodes.entrySet())
{
             String existingName = existing.getKey();
             this.existingChildNodes.put(existingName,
                     new TransientNodeState(existing.getValue(), this, existingName));
         }
         
         // recursively copy all added node states
-        for (Entry<String, TransientNodeState> added : addedNodes.entrySet()) {
+        for (Entry<String, TransientNodeState> added : state.addedNodes.entrySet())
{
             String addedName = added.getKey();
             this.addedNodes.put(addedName,
                     new TransientNodeState(added.getValue(), this, addedName));

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java?rev=1309484&r1=1309483&r2=1309484&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditorTest.java
Wed Apr  4 16:33:00 2012
@@ -93,6 +93,8 @@ public class KernelNodeStateEditorTest {
             assertTrue(expectedPaths.remove(node.getPath()));
         }
         assertTrue(expectedPaths.isEmpty());
+        
+        assertEquals(3, transientState.getChildNodeCount());
     }
 
     @Test
@@ -114,6 +116,8 @@ public class KernelNodeStateEditorTest {
         }
 
         assertTrue(expectedProperties.isEmpty());
+        
+        assertEquals(3, transientState.getPropertyCount());
     }
 
     @Test
@@ -209,4 +213,22 @@ public class KernelNodeStateEditorTest {
         assertNotNull(newState.getChildNode("y").getChildNode("xx"));
     }
 
+    @Test
+    public void deepCopy() {
+        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
+        TransientNodeState transientState = editor.getTransientState();
+        TransientNodeState y = transientState.getChildNode("y");
+
+        editor.edit("x").addNode("x1");
+        editor.copy("x", "y/xx");
+        assertTrue(y.hasNode("xx"));
+        assertTrue(y.getChildNode("xx").hasNode("x1"));
+
+        NodeState newState = editor.mergeInto(microkernel, state);
+        assertNotNull(newState.getChildNode("x"));
+        assertNotNull(newState.getChildNode("y"));
+        assertNotNull(newState.getChildNode("y").getChildNode("xx"));
+        assertNotNull(newState.getChildNode("y").getChildNode("xx").getChildNode("x1"));
+    }
+
 }



Mime
View raw message