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 mr...@apache.org on 2019/09/09 14:23:48 UTC

svn commit: r1866697 - /jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentTest.java

Author: mreutegg
Date: Mon Sep  9 14:23:47 2019
New Revision: 1866697

URL: http://svn.apache.org/viewvc?rev=1866697&view=rev
Log:
OAK-8591: Conflict exception on commit

More tests on NodeDocument.getNodeAtRevision()

Modified:
    jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentTest.java

Modified: jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentTest.java?rev=1866697&r1=1866696&r2=1866697&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentTest.java (original)
+++ jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/NodeDocumentTest.java Mon Sep  9 14:23:47 2019
@@ -491,12 +491,64 @@ public class NodeDocumentTest {
         getNewestRevisionAfterGC(true);
     }
 
+    @Test
+    public void getNodeAtRevisionAfterGC() throws Exception {
+        getNodeAtRevisionAfterGC(false);
+    }
+
+    @Test
+    public void getNodeAtRevisionAfterGCWithBranchRevision() throws Exception {
+        getNodeAtRevisionAfterGC(true);
+    }
+
+    private void getNodeAtRevisionAfterGC(boolean withBranch) throws Exception {
+        DocumentStore store = new MemoryDocumentStore();
+        Revision r = populateStoreAndGC(store);
+
+        // start fresh
+        DocumentNodeStore ns = createTestStore(store, 1, 0, 0);
+        String id = Utils.getIdFromPath(Path.fromString("/bar/test"));
+        NodeDocument doc = store.find(NODES, id);
+        assertNotNull(doc);
+
+        RevisionVector changeRev = new RevisionVector(r);
+        if (withBranch) {
+            changeRev = changeRev.asBranchRevision(1);
+        }
+        DocumentNodeState state = doc.getNodeAtRevision(ns, changeRev, null);
+        assertNotNull(state);
+        assertEquals(changeRev.asTrunkRevision(), state.getLastRevision());
+        assertNotNull(state.getProperty("p"));
+    }
+
     private void getNewestRevisionAfterGC(boolean withBranch) throws Exception {
         DocumentStore store = new MemoryDocumentStore();
+        Revision r = populateStoreAndGC(store);
+
+        // start fresh
+        DocumentNodeStore ns = createTestStore(store, 1, 0, 0);
+        String id = Utils.getIdFromPath(Path.fromString("/bar/test"));
+        NodeDocument doc = store.find(NODES, id);
+        assertNotNull(doc);
+
+        RevisionVector baseRev = ns.getHeadRevision();
+        Revision change = ns.newRevision();
+        Branch branch = null;
+        if (withBranch) {
+            SortedSet<Revision> branchCommits = new TreeSet<>(StableRevisionComparator.REVERSE);
+            branchCommits.add(change);
+            branch = new Branch(branchCommits, baseRev, new ReferenceQueue<>(), null);
+            baseRev = baseRev.asBranchRevision(1);
+        }
+        Revision rev = doc.getNewestRevision(ns, baseRev, change, branch, new HashSet<>());
+        assertEquals(r, rev);
+    }
+
+    private Revision populateStoreAndGC(DocumentStore store) throws Exception {
         DocumentNodeStore ns = createTestStore(store, 1, 0);
         NodeBuilder builder = ns.getRoot().builder();
         builder.child("foo");
-        builder.child("bar").child("test");
+        builder.child("bar").child("test").setProperty("p", "v");
         merge(ns, builder);
         // remember the revision
         Revision r = ns.getHeadRevision().getRevision(1);
@@ -522,23 +574,7 @@ public class NodeDocumentTest {
 
         ns.dispose();
 
-        // start fresh
-        ns = createTestStore(store, 1, 0, 0);
-        String id = Utils.getIdFromPath(Path.fromString("/bar/test"));
-        NodeDocument doc = store.find(NODES, id);
-        assertNotNull(doc);
-
-        RevisionVector baseRev = ns.getHeadRevision();
-        Revision change = ns.newRevision();
-        Branch branch = null;
-        if (withBranch) {
-            SortedSet<Revision> branchCommits = new TreeSet<>(StableRevisionComparator.REVERSE);
-            branchCommits.add(change);
-            branch = new Branch(branchCommits, baseRev, new ReferenceQueue<>(), null);
-            baseRev = baseRev.asBranchRevision(1);
-        }
-        Revision rev = doc.getNewestRevision(ns, baseRev, change, branch, new HashSet<>());
-        assertEquals(r, rev);
+        return r;
     }
 
     @Test