jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1206183 - 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 14:16:02 GMT
Author: stefan
Date: Fri Nov 25 14:16:01 2011
New Revision: 1206183

URL: http://svn.apache.org/viewvc?rev=1206183&view=rev
Log:
fixed NPE on conflicting move
added test case

Added:
    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

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=1206183&r1=1206182&r2=1206183&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 14:16:01 2011
@@ -238,6 +238,9 @@ public class CommitBuilder {
                     // not yet staged, resolve id using staged parent
                     // to allow for staged move operations
                     String id = parent.getChildNodeEntries().get(names[names.length - i -
1]);
+                    if (id == null) {
+                        throw new NotFoundException(nodePath);
+                    }
                     node = new MutableNode(store.getNode(id));
                     staged.put(path, node);
                 }

Added: 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=1206183&view=auto
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java
(added)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConflictingMoveTest.java
Fri Nov 25 14:16:01 2011
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+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;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Test moving nodes.
+ */
+@RunWith(Parameterized.class)
+public class ConflictingMoveTest extends MultiMkTestBase {
+
+    public ConflictingMoveTest(String url) {
+        super(url);
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @Test
+    public void conflictingMove() {
+        String head = mk.getHeadRevision();
+
+        head = mk.commit("/", "+\"a\" : {} \r+\"b\" : {}\n", head, "");
+
+        String r1 = mk.commit("/", ">\"a\" : \"b/a\"", head, "");
+        assertFalse(mk.nodeExists("/a", r1));
+        assertTrue(mk.nodeExists("/b", r1));
+        assertTrue(mk.nodeExists("/b/a", r1));
+
+        try {
+            String r2 = mk.commit("/", ">\"b\" : \"a/b\"", head, "");
+        } catch (MicroKernelException e) {
+            // expected to fail since /a doesn't exist anymore
+            return;
+        }
+        fail();
+    }
+
+    @Test
+    public void conflictingAddDelete() {
+        String head = mk.getHeadRevision();
+
+        head = mk.commit("/", "+\"a\" : {} \r+\"b\" : {}\n", head, "");
+
+        String r1 = mk.commit("/", "-\"b\" \r +\"a/x\" : {}", head, "");
+        assertFalse(mk.nodeExists("/b", r1));
+        assertTrue(mk.nodeExists("/a", r1));
+        assertTrue(mk.nodeExists("/a/x", r1));
+
+        try {
+            String r2 = mk.commit("/", "-\"a\" \r +\"b/x\" : {}", head, "");
+        } catch (MicroKernelException e) {
+            // expected to fail since /b doesn't exist anymore
+            return;
+        }
+        fail();
+    }
+
+}



Mime
View raw message