You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by fr...@apache.org on 2018/04/04 13:40:51 UTC

svn commit: r1828343 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/commit/ThreeWayConflictHandlerTest.java

Author: frm
Date: Wed Apr  4 13:40:50 2018
New Revision: 1828343

URL: http://svn.apache.org/viewvc?rev=1828343&view=rev
Log:
OAK-7388 - Add failing unit test

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/commit/ThreeWayConflictHandlerTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/commit/ThreeWayConflictHandlerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/commit/ThreeWayConflictHandlerTest.java?rev=1828343&r1=1828342&r2=1828343&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/commit/ThreeWayConflictHandlerTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/commit/ThreeWayConflictHandlerTest.java Wed Apr  4 13:40:50 2018
@@ -20,6 +20,7 @@ package org.apache.jackrabbit.oak.plugin
 
 import static org.apache.jackrabbit.oak.api.Type.STRING;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -29,11 +30,15 @@ import org.apache.jackrabbit.oak.api.Con
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState;
+import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.ThreeWayConflictHandler;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
+import org.apache.jackrabbit.oak.spi.state.ConflictAnnotatingRebaseDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class ThreeWayConflictHandlerTest {
@@ -283,6 +288,42 @@ public class ThreeWayConflictHandlerTest
         assertTrue(called.get());
     }
 
+    @Test
+    @Ignore("OAK-7388")
+    public void deletedNodesShouldNotBeRecreated() throws Exception {
+        NodeState root = EmptyNodeState.EMPTY_NODE;
+
+        NodeState withProperty;
+        {
+            NodeBuilder builder = root.builder();
+            builder.child("c").setProperty("foo", "bar");
+            withProperty = builder.getNodeState();
+        }
+
+        NodeState withUpdatedProperty;
+        {
+            NodeBuilder builder = withProperty.builder();
+            builder.child("c").setProperty("foo", "baz");
+            withUpdatedProperty = builder.getNodeState();
+        }
+
+        NodeState withRemovedChild;
+        {
+            NodeBuilder builder = withProperty.builder();
+            builder.child("c").remove();
+            withRemovedChild = builder.getNodeState();
+        }
+
+        NodeBuilder mergedBuilder = withUpdatedProperty.builder();
+        withRemovedChild.compareAgainstBaseState(withProperty, new ConflictAnnotatingRebaseDiff(mergedBuilder));
+        NodeState merged = ConflictHook.of(DefaultThreeWayConflictHandler.OURS).processCommit(
+            mergedBuilder.getBaseState(),
+            mergedBuilder.getNodeState(),
+            CommitInfo.EMPTY
+        );
+        assertFalse(merged.hasChildNode("c"));
+    }
+
     private static ContentRepository newRepo(ThreeWayConflictHandler handler) {
         return new Oak().with(new OpenSecurityProvider()).with(handler).createContentRepository();
     }