jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1206201 - in /jackrabbit/sandbox/microkernel/src: main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java
Date Fri, 25 Nov 2011 15:00:14 GMT
Author: stefan
Date: Fri Nov 25 15:00:13 2011
New Revision: 1206201

URL: http://svn.apache.org/viewvc?rev=1206201&view=rev
Log:
move must not overwrite existing node at destination path

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java?rev=1206201&r1=1206200&r2=1206201&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
(original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
Fri Nov 25 15:00:13 2011
@@ -103,6 +103,9 @@ public class CommitBuilder {
         srcParent.getChildNodeEntries().remove(srcNodeName);
 
         MutableNode destParent = getOrCreateStagedNode(destParentPath);
+        if (destParent.getChildNodeEntries().containsKey(destNodeName)) {
+            throw new Exception("node already exists at move destination path: " + destPath);
+        }
         destParent.getChildNodeEntries().put(destNodeName, targetId);
 
         // update staging area

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java?rev=1206201&r1=1206200&r2=1206201&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java
Fri Nov 25 15:00:13 2011
@@ -16,12 +16,8 @@
  */
 package org.apache.jackrabbit.mk;
 
-import junit.framework.Assert;
-import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.api.MicroKernelException;
-import org.apache.jackrabbit.mk.json.JsopTokenizer;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -46,6 +42,20 @@ public class ConflictingMoveTest extends
     }
 
     @Test
+    public void collidingMove() {
+        String head = mk.getHeadRevision();
+
+        head = mk.commit("/", "+\"x\" : {} \r+\"y\" : {}\n", head, "");
+
+        try {
+            String r1 = mk.commit("/", ">\"x\" : \"y\"", head, "");
+            fail("expected to fail since /y already exists");
+        } catch (MicroKernelException e) {
+            // expected
+        }
+    }
+
+    @Test
     public void conflictingMove() {
         String head = mk.getHeadRevision();
 
@@ -58,11 +68,10 @@ public class ConflictingMoveTest extends
 
         try {
             String r2 = mk.commit("/", ">\"b\" : \"a/b\"", head, "");
+            fail("expected to fail since /a doesn't exist");
         } catch (MicroKernelException e) {
-            // expected to fail since /a doesn't exist anymore
-            return;
+            // expected
         }
-        fail();
     }
 
     @Test



Mime
View raw message