jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1309705 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/kernel/ test/java/org/apache/jackrabbit/oak/kernel/
Date Thu, 05 Apr 2012 09:06:15 GMT
Author: mduerig
Date: Thu Apr  5 09:06:15 2012
New Revision: 1309705

URL: http://svn.apache.org/viewvc?rev=1309705&view=rev
Log:
OAK-9: Internal tree builder
property and node count tests
fix: wrong property count if setting an existing property

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java
    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/KernelNodeStateEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java?rev=1309705&r1=1309704&r2=1309705&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateEditor.java
Thu Apr  5 09:06:15 2012
@@ -163,7 +163,7 @@ public class KernelNodeStateEditor imple
      * @param target target of the merge operation
      * @return node state resulting from merging
      */
-    NodeState mergeInto(MicroKernel microkernel, KernelNodeState target) {
+    KernelNodeState mergeInto(MicroKernel microkernel, KernelNodeState target) {
         String targetPath = target.getPath();
         String targetRevision = target.getRevision();
         String rev = microkernel.commit(targetPath, jsop.toString(), targetRevision, null);

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=1309705&r1=1309704&r2=1309705&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
Thu Apr  5 09:06:15 2012
@@ -346,6 +346,13 @@ public class TransientNodeState {
     }
 
     /**
+     * @return  the name of this transient node state
+     */
+    String getName() {
+        return name;
+    }
+
+    /**
      * @return  relative path of this transient node state
      */
     String getPath() {
@@ -388,6 +395,9 @@ public class TransientNodeState {
      * @param state  a property state
      */
     void setProperty(PropertyState state) {
+        if (hasExistingProperty(state.getName())) {
+            removedProperties.add(state.getName());
+        }
         addedProperties.put(state.getName(), state);
     }
 

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=1309705&r1=1309704&r2=1309705&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
Thu Apr  5 09:06:15 2012
@@ -24,6 +24,7 @@ import org.apache.jackrabbit.mk.model.Sc
 import org.apache.jackrabbit.mk.model.Scalar.Type;
 import org.apache.jackrabbit.mk.model.ScalarImpl;
 import org.apache.jackrabbit.mk.simple.SimpleKernelImpl;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -54,6 +55,11 @@ public class KernelNodeStateEditorTest {
                 "/", jsop, microkernel.getHeadRevision(), "test data");
         state = new KernelNodeState(microkernel, "/test", revision);
     }
+    
+    @After
+    public void tearDown() {
+        microkernel.dispose();
+    }
 
     @Test
     public void getNode() {
@@ -249,5 +255,41 @@ public class KernelNodeStateEditorTest {
         NodeState xx = newState.getChildNode("y").getChildNode("xx");
         assertEquals(x, xx);
     }
+    
+    @Test
+    public void getChildNodeCount() {
+        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
+        TransientNodeState transientState = editor.getTransientState();
+        assertEquals(3, transientState.getChildNodeCount());
+
+        transientState.removeNode("x");
+        assertEquals(2, transientState.getChildNodeCount());
+
+        transientState.addNode("a");
+        assertEquals(3, transientState.getChildNodeCount());
+
+        transientState.addNode("x");
+        assertEquals(4, transientState.getChildNodeCount());
+    }
+    
+    @Test
+    public void getPropertyCount() {
+        KernelNodeStateEditor editor = new KernelNodeStateEditor(state);
+        TransientNodeState transientState = editor.getTransientState();
+        assertEquals(3, transientState.getPropertyCount());
+
+        Scalar value = ScalarImpl.stringScalar("foo");
+        transientState.setProperty(new KernelPropertyState("a", value));
+        assertEquals(3, transientState.getPropertyCount());
+
+        transientState.removeProperty("a");
+        assertEquals(2, transientState.getPropertyCount());
+
+        transientState.setProperty(new KernelPropertyState("x", value));
+        assertEquals(3, transientState.getPropertyCount());
+
+        transientState.setProperty(new KernelPropertyState("a", value));
+        assertEquals(4, transientState.getPropertyCount());
+    }
 
 }



Mime
View raw message