jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1458815 - /jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/SimpleTest.java
Date Wed, 20 Mar 2013 12:59:17 GMT
Author: mreutegg
Date: Wed Mar 20 12:59:16 2013
New Revision: 1458815

URL: http://svn.apache.org/r1458815
Log:
OAK-619 Lock-free MongoMK implementation
- add test for commit root annotation

Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/SimpleTest.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/SimpleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/SimpleTest.java?rev=1458815&r1=1458814&r2=1458815&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/SimpleTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/prototype/SimpleTest.java
Wed Mar 20 12:59:16 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.mongomk.prototype;
 
+import java.util.Map;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
@@ -303,6 +305,47 @@ public class SimpleTest {
         assertTrue(mk.nodeExists("/root/c/b", head));
     }
 
+    @Test
+    public void commitRoot() {
+        MongoMK mk = createMK();
+        try {
+            DocumentStore store = mk.getDocumentStore();
+            String head = mk.getHeadRevision();
+            head = mk.commit("", "+\"/test\":{\"foo\":{}}", head, null);
+
+            // root node must not have the revision
+            Map<String, Object> rootNode = store.find(Collection.NODES, "0:/");
+            assertFalse(((Map) rootNode.get(UpdateOp.REVISIONS)).containsKey(head));
+
+            // test node must have head in revisions
+            Map<String, Object> node = store.find(Collection.NODES, "1:/test");
+            assertTrue(((Map) node.get(UpdateOp.REVISIONS)).containsKey(head));
+
+            // foo must not have head in revisions and must refer to test
+            // as commit root (depth = 1)
+            Map<String, Object> foo = store.find(Collection.NODES, "2:/test/foo");
+            assertTrue(foo.get(UpdateOp.REVISIONS) == null);
+            assertEquals(1, ((Map) foo.get(UpdateOp.COMMIT_ROOT)).get(head));
+
+            head = mk.commit("", "+\"/bar\":{}+\"/test/foo/bar\":{}", head, null);
+
+            // root node is root of commit
+            rootNode = store.find(Collection.NODES, "0:/");
+            assertTrue(((Map) rootNode.get(UpdateOp.REVISIONS)).containsKey(head));
+
+            // /bar refers to root nodes a commit root
+            Map<String, Object> bar = store.find(Collection.NODES, "1:/bar");
+            assertEquals(0, ((Map) bar.get(UpdateOp.COMMIT_ROOT)).get(head));
+
+            // /test/foo/bar refers to root nodes a commit root
+            bar = store.find(Collection.NODES, "3:/test/foo/bar");
+            assertEquals(0, ((Map) bar.get(UpdateOp.COMMIT_ROOT)).get(head));
+
+        } finally {
+            mk.dispose();
+        }
+    }
+
     private static MongoMK createMK() {
         if (MONGO_DB) {
             DB db = MongoUtils.getConnection().getDB();



Mime
View raw message