jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1332209 - in /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core: RootImplFuzzIT.java RootImplTest.java
Date Mon, 30 Apr 2012 13:56:09 GMT
Author: mduerig
Date: Mon Apr 30 13:56:09 2012
New Revision: 1332209

URL: http://svn.apache.org/viewvc?rev=1332209&view=rev
Log:
OAK-18: Define Oak API
Add test cases for Root.rebase()

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java?rev=1332209&r1=1332208&r2=1332209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
Mon Apr 30 13:56:09 2012
@@ -25,6 +25,7 @@ import org.apache.jackrabbit.oak.api.Cor
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.core.RootImplFuzzIT.Operation.Rebase;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
 import org.junit.Before;
 import org.junit.Test;
@@ -267,12 +268,24 @@ public class RootImplFuzzIT {
                 return "save";
             }
         }
+
+        static class Rebase extends Operation {
+            @Override
+            void apply(RootImpl root) {
+                root.rebase();
+            }
+
+            @Override
+            public String toString() {
+                return "rebase";
+            }
+        }
     }
 
     private Operation createOperation() {
         Operation op;
         do {
-            switch (random.nextInt(10)) {
+            switch (random.nextInt(11)) {
                 case 0:
                 case 1:
                 case 2:
@@ -300,6 +313,9 @@ public class RootImplFuzzIT {
                 case 9:
                     op = new Save();
                     break;
+                case 10:
+                    op = new Rebase();
+                    break;
                 default:
                     throw new IllegalStateException();
             }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java?rev=1332209&r1=1332208&r2=1332209&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
Mon Apr 30 13:56:09 2012
@@ -25,7 +25,6 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Tree.Status;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -411,7 +410,31 @@ public class RootImplTest extends Abstra
         assertEquals(Status.EXISTING, tree.getChildStatus("one"));
         assertEquals(Status.MODIFIED, tree.getChild("one").getChildStatus("two"));
     }
-    
+
+    @Test
+    public void rebase() throws CommitFailedException {
+        RootImpl root1 = new RootImpl(store, "test");
+        RootImpl root2 = new RootImpl(store, "test");
+
+        checkEqual(root1.getTree("/"), root2.getTree("/"));
+
+        CoreValue value = valueFactory.createValue("V1");
+        root2.getTree("/").addChild("one").addChild("two").addChild("three")
+                .setProperty("p1", value);
+        root2.commit();
+
+        root1.rebase();
+        checkEqual(root1.getTree("/"), (root2.getTree("/")));
+
+        Tree one = root2.getTree("/one");
+        one.removeChild("two");
+        one.addChild("four");
+        root2.commit();
+
+        root1.rebase();
+        checkEqual(root1.getTree("/"), (root2.getTree("/")));
+    }
+
     @Test
     @Ignore("WIP") // TODO: move to oak-bench
     public void largeChildList() throws CommitFailedException {



Mime
View raw message