jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1501203 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/mongomk/ test/java/org/apache/jackrabbit/oak/plugins/mongomk/
Date Tue, 09 Jul 2013 11:31:27 GMT
Author: mreutegg
Date: Tue Jul  9 11:31:26 2013
New Revision: 1501203

URL: http://svn.apache.org/r1501203
Log:
OAK-619 Lock-free MongoMK implementation
- Enable some rebase tests

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKRebaseTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKTestBase.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java?rev=1501203&r1=1501202&r2=1501203&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
Tue Jul  9 11:31:26 2013
@@ -1471,16 +1471,22 @@ public class MongoMK implements MicroKer
 
     @Override
     @Nonnull
-    public String rebase(@Nonnull String branchRevisionId, String newBaseRevisionId)
+    public String rebase(@Nonnull String branchRevisionId,
+                         @Nullable String newBaseRevisionId)
             throws MicroKernelException {
+        // TODO conflict handling
         Revision r = Revision.fromString(stripBranchRevMarker(branchRevisionId));
+        Revision base = newBaseRevisionId != null ?
+                Revision.fromString(newBaseRevisionId) :
+                headRevision;
         Branch b = branches.getBranch(r);
         if (b == null) {
-            throw new MicroKernelException(branchRevisionId
-                    + " is not a valid branch revision");
+            // empty branch
+            return "b" + base.toString();
+        }
+        if (b.getBase().equals(base)) {
+            return branchRevisionId;
         }
-        // TODO conflict handling
-        Revision base = Revision.fromString(newBaseRevisionId);
         b.setBase(base);
         // add a pseudo commit to make sure current head of branch
         // has a higher revision than base of branch

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKRebaseTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKRebaseTest.java?rev=1501203&r1=1501202&r2=1501203&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKRebaseTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKRebaseTest.java
Tue Jul  9 11:31:26 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.oak.plugins.mongomk;
 
+import org.json.simple.JSONObject;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -28,7 +29,6 @@ import static org.junit.Assert.assertTru
  * Tests for {@code MicroKernel#rebase}
  * FIXME: this is copied from MicroKernelImplTest. Factor out.
  */
-@Ignore    
 public class MongoMKRebaseTest extends BaseMongoMKTest {
 
     @Test
@@ -47,20 +47,22 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
-    @Ignore    
     public void rebaseEmptyBranch() {
         String branch = mk.branch(null);
         String trunk = mk.commit("", "+\"/a\":{}", null, null);
         String rebased = mk.rebase(branch, null);
 
-        assertEquals("{\":childNodeCount\":1,\"a\":{}}", mk.getNodes("/", rebased, 0, 0,
-1, null));
-        assertEquals("{\":childNodeCount\":1,\"a\":{}}", mk.getNodes("/", null, 0, 0, -1,
null));
+        JSONObject json = parseJSONObject(mk.getNodes("/", rebased, 0, 0, -1, null));
+        assertPropertyValue(json, ":childNodeCount", 1L);
+        assertNotNull(json.get("a"));
+        json = parseJSONObject(mk.getNodes("/", null, 0, 0, -1, null));
+        assertPropertyValue(json, ":childNodeCount", 1L);
+        assertNotNull(json.get("a"));
         assertEquals(trunk, mk.getHeadRevision());
         assertFalse(trunk.equals(rebased));
     }
 
     @Test
-    @Ignore    
     public void rebaseAddNode() {
         mk.commit("", "+\"/x\":{}", null, null);
         String branch = mk.branch(null);
@@ -68,19 +70,18 @@ public class MongoMKRebaseTest extends B
         mk.commit("", "+\"/x/a\":{}", null, null);
         String rebased = mk.rebase(branch, null);
 
-        assertEquals(1, mk.getChildNodeCount("/x", null));
+        assertChildNodeCount("/x", null, 1);
         assertNotNull(mk.getNodes("/x/a", null, 0, 0, -1, null));
 
-        assertEquals(1, mk.getChildNodeCount("/x", branch));
+        assertChildNodeCount("/x", branch, 1);
         assertNotNull(mk.getNodes("/x/b", branch, 0, 0, -1, null));
 
-        assertEquals(2, mk.getChildNodeCount("/x", rebased));
+        assertChildNodeCount("/x", rebased, 2);
         assertNotNull(mk.getNodes("/x/a", rebased, 0, 0, -1, null));
         assertNotNull(mk.getNodes("/x/b", rebased, 0, 0, -1, null));
     }
 
     @Test
-    @Ignore    
     public void rebaseRemoveNode() {
         mk.commit("", "+\"/x\":{\"y\":{}}", null, null);
         String branch = mk.branch(null);
@@ -88,18 +89,18 @@ public class MongoMKRebaseTest extends B
         mk.commit("", "+\"/x/a\":{}", null, null);
         String rebased = mk.rebase(branch, null);
 
-        assertEquals(2, mk.getChildNodeCount("/x", null));
+        assertChildNodeCount("/x", null, 2);
         assertNotNull(mk.getNodes("/x/a", null, 0, 0, -1, null));
         assertNotNull(mk.getNodes("/x/y", null, 0, 0, -1, null));
 
-        assertEquals(0, mk.getChildNodeCount("/x", branch));
+        assertChildNodeCount("/x", branch, 0);
 
-        assertEquals(1, mk.getChildNodeCount("/x", rebased));
+        assertChildNodeCount("/x", rebased, 1);
         assertNotNull(mk.getNodes("/x/a", rebased, 0, 0, -1, null));
     }
 
     @Test
-    @Ignore    
+    @Ignore
     public void rebaseAddProperty() {
         mk.commit("", "+\"/x\":{\"y\":{}}", null, null);
         String branch = mk.branch(null);
@@ -121,7 +122,7 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
-    @Ignore    
+    @Ignore
     public void rebaseRemoveProperty() {
         mk.commit("", "+\"/x\":{\"y\":{\"p\":42}}", null, null);
         String branch = mk.branch(null);
@@ -143,7 +144,7 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
-    @Ignore    
+    @Ignore
     public void rebaseChangeProperty() {
         mk.commit("", "+\"/x\":{\"y\":{\"p\":42}}", null, null);
         String branch = mk.branch(null);
@@ -183,6 +184,7 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
+    @Ignore("Conflict handling")
     public void rebaseAddExistingNode() {
         mk.commit("", "+\"/x\":{}", null, null);
         String branch = mk.branch(null);
@@ -199,6 +201,7 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
+    @Ignore("Conflict handling")
     public void rebaseAddExistingProperty() {
         mk.commit("", "+\"/x\":{\"y\":{}}", null, null);
         String branch = mk.branch(null);
@@ -216,6 +219,7 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
+    @Ignore("Conflict handling")
     public void rebaseChangeRemovedProperty() {
         mk.commit("", "+\"/x\":{\"y\":{\"p\":42}}", null, null);
         String branch = mk.branch(null);
@@ -233,6 +237,7 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
+    @Ignore("Conflict handling")
     public void rebaseRemoveChangedProperty() {
         mk.commit("", "+\"/x\":{\"y\":{\"p\":42}}", null, null);
         String branch = mk.branch(null);
@@ -250,6 +255,7 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
+    @Ignore("Conflict handling")
     public void rebaseChangedChangedProperty() {
         mk.commit("", "+\"/x\":{\"y\":{\"p\":42}}", null, null);
         String branch = mk.branch(null);
@@ -267,6 +273,7 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
+    @Ignore("Conflict handling")
     public void rebaseRemoveChangedNode() {
         mk.commit("", "+\"/x\":{\"y\":{}}", null, null);
         String branch = mk.branch(null);
@@ -284,6 +291,7 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
+    @Ignore("Conflict handling")
     public void rebaseChangeRemovedNode() {
         mk.commit("", "+\"/x\":{\"y\":{}}", null, null);
         String branch = mk.branch(null);
@@ -301,6 +309,7 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
+    @Ignore("Conflict handling")
     public void rebaseRemoveRemovedProperty() {
         mk.commit("", "+\"/x\":{\"y\":{\"p\":42}}", null, null);
         String branch = mk.branch(null);
@@ -318,6 +327,7 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
+    @Ignore("Conflict handling")
     public void rebaseRemoveRemovedNode() {
         mk.commit("", "+\"/x\":{\"y\":{}}", null, null);
         String branch = mk.branch(null);
@@ -334,7 +344,6 @@ public class MongoMKRebaseTest extends B
     }
 
     @Test
-    @Ignore    
     public void mergeRebased() {
         mk.commit("", "+\"/x\":{\"y\":{}}", null, null);
         String branch = mk.branch(null);

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKTestBase.java?rev=1501203&r1=1501202&r2=1501203&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKTestBase.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMKTestBase.java
Tue Jul  9 11:31:26 2013
@@ -73,6 +73,14 @@ public abstract class MongoMKTestBase {
         doAssertNodes(false, revision, paths);
     }
 
+    protected void assertChildNodeCount(String path,
+                                        String revision,
+                                        long numChildNodes) {
+        JSONObject json = parseJSONObject(getMicroKernel().getNodes(
+                path, revision, 0, 0, -1, null));
+        assertPropertyValue(json, ":childNodeCount", numChildNodes);
+    }
+
     protected void assertPropExists(String rev, String path, String property) {
         String nodes = getMicroKernel().getNodes(path, rev, 0 /*depth*/, 0 /*offset*/, -1
/*maxChildNodes*/, null /*filter*/);
         JSONObject obj = parseJSONObject(nodes);



Mime
View raw message