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 ch...@apache.org on 2017/05/26 06:25:06 UTC

svn commit: r1796239 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java

Author: chetanm
Date: Fri May 26 06:25:05 2017
New Revision: 1796239

URL: http://svn.apache.org/viewvc?rev=1796239&view=rev
Log:
OAK-6267 - Version restore fails if restore would not change bundling root but changes bundled nodes

Add simpler testcase at NodeStore level api which leads to same issue

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java?rev=1796239&r1=1796238&r2=1796239&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java Fri May 26 06:25:05 2017
@@ -45,6 +45,10 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.document.util.Utils;
 import org.apache.jackrabbit.oak.InitialContent;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
+import org.apache.jackrabbit.oak.spi.commit.DefaultEditor;
+import org.apache.jackrabbit.oak.spi.commit.Editor;
+import org.apache.jackrabbit.oak.spi.commit.EditorHook;
+import org.apache.jackrabbit.oak.spi.commit.EditorProvider;
 import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
 import org.apache.jackrabbit.oak.spi.state.AbstractNodeState;
 import org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff;
@@ -54,6 +58,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -667,6 +672,44 @@ public class DocumentBundlingTest {
         merge(builder);
     }
 
+    @Ignore("OAK-6267")
+    @Test
+    public void recreatedBundledNode2() throws Exception{
+        NodeBuilder builder = store.getRoot().builder();
+        NodeBuilder fileNode = newNode("nt:file");
+        fileNode.child("jcr:content").setProperty("jcr:data", "foo");
+        builder.child("test").setChildNode("book.jpg", fileNode.getNodeState());
+        merge(builder);
+
+        builder = store.getRoot().builder();
+        builder.child("a");
+        //In this case we recreate the node in CommitHook
+        store.merge(builder, new EditorHook(new EditorProvider() {
+            @Override
+            public Editor getRootEditor(NodeState before, NodeState after,
+                                        NodeBuilder builder, CommitInfo info) throws CommitFailedException {
+                return new BookRecreatingEditor(builder);
+            }
+        }), CommitInfo.EMPTY);
+    }
+
+    private static class BookRecreatingEditor extends DefaultEditor {
+        final NodeBuilder builder;
+
+        private BookRecreatingEditor(NodeBuilder builder) {
+            this.builder = builder;
+        }
+
+        @Override
+        public void enter(NodeState before, NodeState after) throws CommitFailedException {
+            builder.child("test").remove();
+
+            NodeBuilder book = builder.child("test").child("book.jpg");
+            book.setProperty(JCR_PRIMARYTYPE, "nt:file");
+            book.child("jcr:content");
+        }
+    }
+
     @Test
     public void deleteAndRecreatedBundledNode() throws Exception{
         NodeBuilder builder = store.getRoot().builder();