Author: chetanm
Date: Wed Oct 19 15:11:15 2016
New Revision: 1765643

URL: http://svn.apache.org/viewvc?rev=1765643&view=rev
Log:
OAK-1312 -  [bundling] Bundle nodes into a document

Pass root properties in withRootRevision and fromExternalChange call

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

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java?rev=1765643&r1=1765642&r2=1765643&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
 Wed Oct 19 15:11:15 2016
@@ -150,7 +150,7 @@ public class DocumentNodeState extends A
         if (rootRevision.equals(root) && fromExternalChange == externalChange) 
{
             return this;
         } else {
-            return new DocumentNodeState(store, path, root, properties,
+            return new DocumentNodeState(store, path, root, 
bundlingContext.getAllProperties(),
                     hasChildren, lastRevision, externalChange);
         }
     }
@@ -160,8 +160,8 @@ public class DocumentNodeState extends A
      *          {@link #fromExternalChange} flag set to {@code true}.
      */
     @Nonnull
-    DocumentNodeState fromExternalChange() {
-        return new DocumentNodeState(store, path, rootRevision, properties, 
hasChildren,
+    public DocumentNodeState fromExternalChange() {
+        return new DocumentNodeState(store, path, rootRevision, 
bundlingContext.getAllProperties(), hasChildren,
                 lastRevision, true);
     }
 

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=1765643&r1=1765642&r2=1765643&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
 Wed Oct 19 15:11:15 2016
@@ -30,6 +30,7 @@ import com.google.common.collect.Iterabl
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState;
 import org.apache.jackrabbit.oak.plugins.document.Collection;
 import org.apache.jackrabbit.oak.plugins.document.Document;
 import org.apache.jackrabbit.oak.plugins.document.DocumentMKBuilderProvider;
@@ -63,6 +64,7 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 public class DocumentBundlingTest {
     @Rule
@@ -111,8 +113,13 @@ public class DocumentBundlingTest {
         assertTrue(hasNodeProperty("/test/book.jpg", concat("jcr:content", 
DocumentBundlor.META_PROP_NODE)));
 
         AssertingDiff.assertEquals(fileNode.getNodeState(), 
fileNodeState.getChildNode("book.jpg"));
+
+        DocumentNodeState dns = 
asDocumentState(fileNodeState.getChildNode("book.jpg"));
+        AssertingDiff.assertEquals(fileNode.getNodeState(), 
dns.withRootRevision(dns.getRootRevision(), true));
+        AssertingDiff.assertEquals(fileNode.getNodeState(), 
dns.fromExternalChange());
     }
 
+
     @Test
     public void bundledParent() throws Exception{
         NodeBuilder builder = store.getRoot().builder();
@@ -470,6 +477,14 @@ public class DocumentBundlingTest {
         store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
     }
 
+    private static DocumentNodeState asDocumentState(NodeState state){
+        if (state instanceof DocumentNodeState){
+            return (DocumentNodeState) state;
+        }
+        fail("Not of type AbstractDoucmentNodeState");
+        return null;
+    }
+
     private static void dump(NodeState state){
         System.out.println(NodeStateUtils.toString(state));
     }


Reply via email to