jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1330758 - in /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core: RootImplFuzzIT.java RootImplTest.java
Date Thu, 26 Apr 2012 10:25:39 GMT
Author: mduerig
Date: Thu Apr 26 10:25:38 2012
New Revision: 1330758

URL: http://svn.apache.org/viewvc?rev=1330758&view=rev
Log:
Adding tests and changes to tests which went amiss in revision 1330745

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=1330758&r1=1330757&r2=1330758&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
Thu Apr 26 10:25:38 2012
@@ -75,13 +75,13 @@ public class RootImplFuzzIT {
     public void setup() {
         counter = 0;
 
-        MicroKernel mk1 = new MicroKernelImpl("./target/mk1");
+        MicroKernel mk1 = new MicroKernelImpl("./target/mk1/" + random.nextInt());
         vf = new CoreValueFactoryImpl(mk1);
         store1 = new KernelNodeStore(mk1, vf);
         mk1.commit("", "+\"/test\":{} +\"/test/root\":{}", mk1.getHeadRevision(), "");
         root1 = new RootImpl(store1, "test");
 
-        MicroKernel mk2 = new MicroKernelImpl("./target/mk2");
+        MicroKernel mk2 = new MicroKernelImpl("./target/mk2/" + random.nextInt());
         store2 = new KernelNodeStore(mk2, vf);
         mk2.commit("", "+\"/test\":{} +\"/test/root\":{}", mk2.getHeadRevision(), "");
         root2 = new RootImpl(store2, "test");

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=1330758&r1=1330757&r2=1330758&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
Thu Apr 26 10:25:38 2012
@@ -22,6 +22,7 @@ import org.apache.jackrabbit.oak.api.Com
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Tree.Status;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
 import org.apache.jackrabbit.oak.kernel.NodeState;
 import org.apache.jackrabbit.oak.kernel.NodeStore;
@@ -337,6 +338,78 @@ public class RootImplTest extends Abstra
     }
 
     @Test
+    public void addAndRemoveProperty() throws CommitFailedException {
+        RootImpl root = new RootImpl(store, "test");
+        Tree tree = root.getTree("/");
+
+        tree.setProperty("P0", valueFactory.createValue("V1"));
+        root.commit();
+        tree = root.getTree("/");
+        assertTrue(tree.hasProperty("P0"));
+
+        tree.removeProperty("P0");
+        root.commit();
+        tree = root.getTree("/");
+        assertFalse(tree.hasProperty("P0"));
+    }
+
+    @Test
+    public void nodeStatus() throws CommitFailedException {
+        RootImpl root = new RootImpl(store, "test");
+        Tree tree = root.getTree("/");
+
+        tree.addChild("new");
+        assertEquals(Status.NEW, tree.getChildStatus("new"));
+        root.commit();
+
+        tree = root.getTree("/");
+        assertEquals(Status.EXISTING, tree.getChildStatus("new"));
+        Tree added = tree.getChild("new");
+        added.addChild("another");
+        assertEquals(Status.MODIFIED, tree.getChildStatus("new"));
+        root.commit();
+
+        tree = root.getTree("/");
+        assertEquals(Status.EXISTING, tree.getChildStatus("new"));
+        tree.getChild("new").removeChild("another");
+        assertEquals(Status.MODIFIED, tree.getChildStatus("new"));
+        assertEquals(Status.REMOVED, tree.getChild("new").getChildStatus("another"));
+        root.commit();
+
+        tree = root.getTree("/");
+        assertEquals(Status.EXISTING, tree.getChildStatus("new"));
+        assertNull(tree.getChild("new").getChild("another"));
+        assertNull(tree.getChild("new").getChildStatus("another"));
+    }
+
+    @Test
+    public void propertyStatus() throws CommitFailedException {
+        RootImpl root = new RootImpl(store, "test");
+        Tree tree = root.getTree("/");
+        CoreValue value1 = valueFactory.createValue("V1");
+        CoreValue value2 = valueFactory.createValue("V2");
+
+        tree.setProperty("new", value1);
+        assertEquals(Status.NEW, tree.getPropertyStatus("new"));
+        root.commit();
+
+        tree = root.getTree("/");
+        assertEquals(Status.EXISTING, tree.getPropertyStatus("new"));
+        tree.setProperty("new", value2);
+        assertEquals(Status.MODIFIED, tree.getPropertyStatus("new"));
+        root.commit();
+
+        tree = root.getTree("/");
+        assertEquals(Status.EXISTING, tree.getPropertyStatus("new"));
+        tree.removeProperty("new");
+        assertEquals(Status.REMOVED, tree.getPropertyStatus("new"));
+        root.commit();
+
+        tree = root.getTree("/");
+        assertNull(tree.getPropertyStatus("new"));
+    }
+    
+    @Test
     @Ignore("WIP") // FIXME: causes OOME since the branch/merge feature from OAK-45 is used
     public void largeChildList() throws CommitFailedException {
         RootImpl root = new RootImpl(store, "test");



Mime
View raw message