jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1400013 - in /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak: core/ kernel/
Date Fri, 19 Oct 2012 09:41:23 GMT
Author: jukka
Date: Fri Oct 19 09:41:23 2012
New Revision: 1400013

URL: http://svn.apache.org/viewvc?rev=1400013&view=rev
Log:
OAK-352: Oak builder for simplified repository construction

Simplify test cases using the Oak class

Removed:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultConflictHandlerTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultConflictHandlerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultConflictHandlerTest.java?rev=1400013&r1=1400012&r2=1400013&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultConflictHandlerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultConflictHandlerTest.java
Fri Oct 19 09:41:23 2012
@@ -18,81 +18,97 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.plugins.commit.DefaultConflictHandler;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+public class DefaultConflictHandlerTest {
+
+    private static final String OUR_VALUE = "foo";
+    private static final String THEIR_VALUE = "bar";
 
-public class DefaultConflictHandlerTest extends AbstractCoreTest {
     private RootImpl ourRoot;
     private Root theirRoot;
-    private String ourValue;
-    private String theirValue;
 
-    @Override
-    protected NodeState createInitialState(MicroKernel microKernel) {
-        String jsop = "^\"a\":1 ^\"b\":2 ^\"c\":3 +\"x\":{} +\"y\":{} +\"z\":{}";
-        microKernel.commit("/", jsop, microKernel.getHeadRevision(), "test data");
-
-        ourRoot = createRootImpl("");
-        theirRoot = createRootImpl("");
-
-        ourValue = "foo";
-        theirValue = "bar";
-        return store.getRoot();
+    @Before
+    public void setUp() throws CommitFailedException {
+        ContentSession session = new Oak().createContentSession();
+
+        // Add test content
+        Root root = session.getLatestRoot();
+        Tree tree = root.getTree("/");
+        tree.setProperty("a", 1);
+        tree.setProperty("b", 2);
+        tree.setProperty("c", 3);
+        tree.addChild("x");
+        tree.addChild("y");
+        tree.addChild("z");
+        root.commit();
+
+        ourRoot = (RootImpl) session.getLatestRoot();
+        theirRoot = session.getLatestRoot();
+    }
+
+    @After
+    public void tearDown() {
+        ourRoot = null;
+        theirRoot = null;
     }
 
     @Test
     public void testAddExistingPropertyOurs() throws CommitFailedException {
-        theirRoot.getTree("/").setProperty("p", theirValue);
-        ourRoot.getTree("/").setProperty("p", ourValue);
+        theirRoot.getTree("/").setProperty("p", THEIR_VALUE);
+        ourRoot.getTree("/").setProperty("p", OUR_VALUE);
 
         theirRoot.commit();
         ourRoot.commit();
 
         PropertyState p = ourRoot.getTree("/").getProperty("p");
         assertNotNull(p);
-        assertEquals(ourValue, p.getValue(STRING));
+        assertEquals(OUR_VALUE, p.getValue(STRING));
     }
 
     @Test
     public void testChangeDeletedPropertyOurs() throws CommitFailedException {
         theirRoot.getTree("/").removeProperty("a");
-        ourRoot.getTree("/").setProperty("a", ourValue);
+        ourRoot.getTree("/").setProperty("a", OUR_VALUE);
 
         theirRoot.commit();
         ourRoot.commit();
 
         PropertyState p = ourRoot.getTree("/").getProperty("a");
         assertNotNull(p);
-        assertEquals(ourValue, p.getValue(STRING));
+        assertEquals(OUR_VALUE, p.getValue(STRING));
     }
 
     @Test
     public void testChangeChangedPropertyOurs() throws CommitFailedException {
-        theirRoot.getTree("/").setProperty("a", theirValue);
-        ourRoot.getTree("/").setProperty("a", ourValue);
+        theirRoot.getTree("/").setProperty("a", THEIR_VALUE);
+        ourRoot.getTree("/").setProperty("a", OUR_VALUE);
 
         theirRoot.commit();
         ourRoot.commit();
 
         PropertyState p = ourRoot.getTree("/").getProperty("a");
         assertNotNull(p);
-        assertEquals(ourValue, p.getValue(STRING));
+        assertEquals(OUR_VALUE, p.getValue(STRING));
     }
 
     @Test
     public void testDeleteChangedPropertyOurs() throws CommitFailedException {
-        theirRoot.getTree("/").setProperty("a", theirValue);
+        theirRoot.getTree("/").setProperty("a", THEIR_VALUE);
         ourRoot.getTree("/").removeProperty("a");
 
         theirRoot.commit();
@@ -104,33 +120,33 @@ public class DefaultConflictHandlerTest 
 
     @Test
     public void testAddExistingNodeOurs() throws CommitFailedException {
-        theirRoot.getTree("/").addChild("n").setProperty("p", theirValue);
-        ourRoot.getTree("/").addChild("n").setProperty("p", ourValue);
+        theirRoot.getTree("/").addChild("n").setProperty("p", THEIR_VALUE);
+        ourRoot.getTree("/").addChild("n").setProperty("p", OUR_VALUE);
 
         theirRoot.commit();
         ourRoot.commit();
 
         Tree n = ourRoot.getTree("/n");
         assertNotNull(n);
-        assertEquals(ourValue, n.getProperty("p").getValue(STRING));
+        assertEquals(OUR_VALUE, n.getProperty("p").getValue(STRING));
     }
 
     @Test
     public void testChangeDeletedNodeOurs() throws CommitFailedException {
         theirRoot.getTree("/x").remove();
-        ourRoot.getTree("/x").setProperty("p", ourValue);
+        ourRoot.getTree("/x").setProperty("p", OUR_VALUE);
 
         theirRoot.commit();
         ourRoot.commit();
 
         Tree n = ourRoot.getTree("/x");
         assertNotNull(n);
-        assertEquals(ourValue, n.getProperty("p").getValue(STRING));
+        assertEquals(OUR_VALUE, n.getProperty("p").getValue(STRING));
     }
 
     @Test
     public void testDeleteChangedNodeOurs() throws CommitFailedException {
-        theirRoot.getTree("/x").setProperty("p", theirValue);
+        theirRoot.getTree("/x").setProperty("p", THEIR_VALUE);
         ourRoot.getTree("/x").remove();
 
         theirRoot.commit();
@@ -142,8 +158,8 @@ public class DefaultConflictHandlerTest 
 
     @Test
     public void testAddExistingPropertyTheirs() throws CommitFailedException {
-        theirRoot.getTree("/").setProperty("p", theirValue);
-        ourRoot.getTree("/").setProperty("p", ourValue);
+        theirRoot.getTree("/").setProperty("p", THEIR_VALUE);
+        ourRoot.getTree("/").setProperty("p", OUR_VALUE);
 
         theirRoot.commit();
         ourRoot.setConflictHandler(DefaultConflictHandler.THEIRS);
@@ -151,13 +167,13 @@ public class DefaultConflictHandlerTest 
 
         PropertyState p = ourRoot.getTree("/").getProperty("p");
         assertNotNull(p);
-        assertEquals(theirValue, p.getValue(STRING));
+        assertEquals(THEIR_VALUE, p.getValue(STRING));
     }
 
     @Test
     public void testChangeDeletedPropertyTheirs() throws CommitFailedException {
         theirRoot.getTree("/").removeProperty("a");
-        ourRoot.getTree("/").setProperty("a", ourValue);
+        ourRoot.getTree("/").setProperty("a", OUR_VALUE);
 
         theirRoot.commit();
         ourRoot.setConflictHandler(DefaultConflictHandler.THEIRS);
@@ -169,8 +185,8 @@ public class DefaultConflictHandlerTest 
 
     @Test
     public void testChangeChangedPropertyTheirs() throws CommitFailedException {
-        theirRoot.getTree("/").setProperty("a", theirValue);
-        ourRoot.getTree("/").setProperty("a", ourValue);
+        theirRoot.getTree("/").setProperty("a", THEIR_VALUE);
+        ourRoot.getTree("/").setProperty("a", OUR_VALUE);
 
         theirRoot.commit();
         ourRoot.setConflictHandler(DefaultConflictHandler.THEIRS);
@@ -178,12 +194,12 @@ public class DefaultConflictHandlerTest 
 
         PropertyState p = ourRoot.getTree("/").getProperty("a");
         assertNotNull(p);
-        assertEquals(theirValue, p.getValue(STRING));
+        assertEquals(THEIR_VALUE, p.getValue(STRING));
     }
 
     @Test
     public void testDeleteChangedPropertyTheirs() throws CommitFailedException {
-        theirRoot.getTree("/").setProperty("a", theirValue);
+        theirRoot.getTree("/").setProperty("a", THEIR_VALUE);
         ourRoot.getTree("/").removeProperty("a");
 
         theirRoot.commit();
@@ -192,13 +208,13 @@ public class DefaultConflictHandlerTest 
 
         PropertyState p = ourRoot.getTree("/").getProperty("a");
         assertNotNull(p);
-        assertEquals(theirValue, p.getValue(STRING));
+        assertEquals(THEIR_VALUE, p.getValue(STRING));
     }
 
     @Test
     public void testAddExistingNodeTheirs() throws CommitFailedException {
-        theirRoot.getTree("/").addChild("n").setProperty("p", theirValue);
-        ourRoot.getTree("/").addChild("n").setProperty("p", ourValue);
+        theirRoot.getTree("/").addChild("n").setProperty("p", THEIR_VALUE);
+        ourRoot.getTree("/").addChild("n").setProperty("p", OUR_VALUE);
 
         theirRoot.commit();
         ourRoot.setConflictHandler(DefaultConflictHandler.THEIRS);
@@ -206,13 +222,13 @@ public class DefaultConflictHandlerTest 
 
         Tree n = ourRoot.getTree("/n");
         assertNotNull(n);
-        assertEquals(theirValue, n.getProperty("p").getValue(STRING));
+        assertEquals(THEIR_VALUE, n.getProperty("p").getValue(STRING));
     }
 
     @Test
     public void testChangeDeletedNodeTheirs() throws CommitFailedException {
         theirRoot.getTree("/x").remove();
-        ourRoot.getTree("/x").setProperty("p", ourValue);
+        ourRoot.getTree("/x").setProperty("p", OUR_VALUE);
 
         theirRoot.commit();
         ourRoot.setConflictHandler(DefaultConflictHandler.THEIRS);
@@ -224,7 +240,7 @@ public class DefaultConflictHandlerTest 
 
     @Test
     public void testDeleteChangedNodeTheirs() throws CommitFailedException {
-        theirRoot.getTree("/x").setProperty("p", theirValue);
+        theirRoot.getTree("/x").setProperty("p", THEIR_VALUE);
         ourRoot.getTree("/").remove();
 
         theirRoot.commit();
@@ -232,7 +248,7 @@ public class DefaultConflictHandlerTest 
 
         Tree n = ourRoot.getTree("/x");
         assertNotNull(n);
-        assertEquals(theirValue, n.getProperty("p").getValue(STRING));
+        assertEquals(THEIR_VALUE, n.getProperty("p").getValue(STRING));
     }
 
 }

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=1400013&r1=1400012&r2=1400013&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
Fri Oct 19 09:41:23 2012
@@ -21,11 +21,14 @@ package org.apache.jackrabbit.oak.core;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -34,18 +37,36 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-public class RootImplTest extends AbstractCoreTest {
+public class RootImplTest {
 
-    @Override
-    protected NodeState createInitialState(MicroKernel microKernel) {
-        String jsop = "^\"a\":1 ^\"b\":2 ^\"c\":3 +\"x\":{\"xx\":{},\"xa\":\"value\"} +\"y\":{}
+\"z\":{}";
-        microKernel.commit("/", jsop, microKernel.getHeadRevision(), "test data");
-        return store.getRoot();
+    private ContentSession session;
+
+    @Before
+    public void setUp() throws CommitFailedException {
+        session = new Oak().createContentSession();
+
+        // Add test content
+        Root root = session.getLatestRoot();
+        Tree tree = root.getTree("/");
+        tree.setProperty("a", 1);
+        tree.setProperty("b", 2);
+        tree.setProperty("c", 3);
+        Tree x = tree.addChild("x");
+        x.addChild("xx");
+        x.setProperty("xa", "value");
+        tree.addChild("y");
+        tree.addChild("z");
+        root.commit();
+    }
+
+    @After
+    public void tearDown() {
+        session = null;
     }
 
     @Test
     public void getTree() {
-        RootImpl root = createRootImpl(null);
+        Root root = session.getLatestRoot();
 
         List<String> validPaths = new ArrayList<String>();
         validPaths.add("/");
@@ -71,7 +92,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void move() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
+        Root root = session.getLatestRoot();
         Tree tree = root.getTree("/");
 
         Tree y = tree.getChild("y");
@@ -91,7 +112,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void move2() {
-        RootImpl root = createRootImpl(null);
+        Root root = session.getLatestRoot();
         Tree r = root.getTree("/");
         Tree x = r.getChild("x");
         Tree y = r.getChild("y");
@@ -103,12 +124,12 @@ public class RootImplTest extends Abstra
         assertEquals("y", x.getParent().getName());
     }
 
-    @Test
     /**
      * Regression test for OAK-208
      */
+    @Test
     public void removeMoved() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
+        Root root = session.getLatestRoot();
         Tree r = root.getTree("/");
         r.addChild("a");
         r.addChild("b");
@@ -128,7 +149,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void rename() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
+        Root root = session.getLatestRoot();
         Tree tree = root.getTree("/");
 
         assertTrue(tree.hasChild("x"));
@@ -145,7 +166,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void copy() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
+        Root root = session.getLatestRoot();
         Tree tree = root.getTree("/");
 
         Tree y = tree.getChild("y");
@@ -165,7 +186,7 @@ public class RootImplTest extends Abstra
 
     @Test
     public void deepCopy() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
+        Root root = session.getLatestRoot();
         Tree tree = root.getTree("/");
 
         Tree y = tree.getChild("y");
@@ -190,8 +211,8 @@ public class RootImplTest extends Abstra
 
     @Test
     public void rebase() throws CommitFailedException {
-        RootImpl root1 = createRootImpl(null);
-        RootImpl root2 = createRootImpl(null);
+        Root root1 = session.getLatestRoot();
+        Root root2 = session.getLatestRoot();
 
         checkEqual(root1.getTree("/"), root2.getTree("/"));
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java?rev=1400013&r1=1400012&r2=1400013&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
Fri Oct 19 09:41:23 2012
@@ -21,13 +21,16 @@ import java.util.HashSet;
 import java.util.Set;
 
 import com.google.common.collect.Sets;
-import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Tree.Status;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
 import static org.apache.jackrabbit.oak.api.Type.LONG;
@@ -41,19 +44,36 @@ import static org.junit.Assert.assertTru
 /**
  * TreeImplTest...
  */
-public class TreeImplTest extends AbstractCoreTest {
+public class TreeImplTest {
 
-    @Override
-    protected NodeState createInitialState(MicroKernel microKernel) {
-        String jsop = "^\"a\":1 ^\"b\":2 ^\"c\":3 +\"x\":{} +\"y\":{} +\"z\":{}";
-        microKernel.commit("/", jsop, microKernel.getHeadRevision(), "test data");
-        return store.getRoot();
+    private Root root;
+
+    @Before
+    public void setUp() throws CommitFailedException {
+        ContentSession session = new Oak().createContentSession();
+
+        // Add test content
+        root = session.getLatestRoot();
+        Tree tree = root.getTree("/");
+        tree.setProperty("a", 1);
+        tree.setProperty("b", 2);
+        tree.setProperty("c", 3);
+        tree.addChild("x");
+        tree.addChild("y");
+        tree.addChild("z");
+        root.commit();
+
+        // Acquire a fresh new root to avoid problems from lingering state
+        root = session.getLatestRoot();
     }
 
+    @After
+    public void tearDown() {
+        root = null;
+    }
 
     @Test
     public void getChild() {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         Tree child = tree.getChild("any");
@@ -65,7 +85,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void getProperty() {
-        RootImpl root = createRootImpl("test");
         Tree tree = root.getTree("/");
 
         PropertyState propertyState = tree.getProperty("any");
@@ -80,7 +99,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void getChildren() {
-        RootImpl root = createRootImpl("test");
         Tree tree = root.getTree("/");
 
         Iterable<Tree> children = tree.getChildren();
@@ -98,7 +116,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void getProperties() {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         Set<PropertyState> expectedProperties = Sets.newHashSet(
@@ -117,7 +134,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void addChild() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         assertFalse(tree.hasChild("new"));
@@ -137,7 +153,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void addExistingChild() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         assertFalse(tree.hasChild("new"));
@@ -154,7 +169,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void removeChild() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         assertTrue(tree.hasChild("x"));
@@ -169,7 +183,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void setProperty() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         assertFalse(tree.hasProperty("new"));
@@ -190,7 +203,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void removeProperty() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         assertTrue(tree.hasProperty("a"));
@@ -205,7 +217,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void getChildrenCount() {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         assertEquals(3, tree.getChildrenCount());
@@ -222,7 +233,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void getPropertyCount() {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         assertEquals(3, tree.getPropertyCount());
@@ -242,7 +252,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void addAndRemoveProperty() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         tree.setProperty("P0", "V1");
@@ -258,7 +267,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void nodeStatus() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         tree.addChild("new");
@@ -291,7 +299,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void propertyStatus() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         tree.setProperty("new", "value1");
@@ -321,7 +328,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void noTransitiveModifiedStatus() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
         tree.addChild("one").addChild("two");
         root.commit();
@@ -334,7 +340,6 @@ public class TreeImplTest extends Abstra
 
     @Test
     public void largeChildList() throws CommitFailedException {
-        RootImpl root = createRootImpl(null);
         Tree tree = root.getTree("/");
 
         Set<String> added = new HashSet<String>();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java?rev=1400013&r1=1400012&r2=1400013&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
Fri Oct 19 09:41:23 2012
@@ -23,11 +23,16 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.core.AbstractCoreTest;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
 import static junit.framework.Assert.assertEquals;
@@ -35,15 +40,30 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.assertNull;
 import static org.apache.jackrabbit.oak.api.Type.LONG;
 
-public class KernelNodeStateTest extends AbstractCoreTest {
+public class KernelNodeStateTest {
 
-    @Override
-    protected NodeState createInitialState(MicroKernel microKernel) {
-        String jsop =
-                "+\"test\":{\"a\":1,\"b\":2,\"c\":3,"
-                + "\"x\":{},\"y\":{},\"z\":{}}";
-        microKernel.commit("/", jsop, null, "test data");
-        return store.getRoot().getChildNode("test");
+    private NodeState state;
+
+    @Before
+    public void setUp() throws CommitFailedException {
+        NodeStore store = new KernelNodeStore(new MicroKernelImpl());
+        NodeStoreBranch branch = store.branch();
+
+        NodeBuilder builder = branch.getRoot().builder();
+        builder.setProperty("a", 1);
+        builder.setProperty("b", 2);
+        builder.setProperty("c", 3);
+        builder.child("x");
+        builder.child("y");
+        builder.child("z");
+        branch.setRoot(builder.getNodeState());
+
+        state = branch.merge();
+    }
+
+    @After
+    public void tearDown() {
+        state = null;
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java?rev=1400013&r1=1400012&r2=1400013&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
Fri Oct 19 09:41:23 2012
@@ -18,28 +18,45 @@
  */
 package org.apache.jackrabbit.oak.kernel;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.oak.core.AbstractCoreTest;
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertNull;
 
-public class LargeKernelNodeStateTest extends AbstractCoreTest {
+public class LargeKernelNodeStateTest {
+
     private static final int N = KernelNodeState.MAX_CHILD_NODE_NAMES;
 
-    @Override
-    protected NodeState createInitialState(MicroKernel microKernel) {
-        StringBuilder jsop = new StringBuilder("+\"test\":{\"a\":1");
+    private NodeState state;
+
+    @Before
+    public void setUp() throws CommitFailedException {
+        NodeStore store = new KernelNodeStore(new MicroKernelImpl());
+        NodeStoreBranch branch = store.branch();
+
+        NodeBuilder builder = branch.getRoot().builder();
+        builder.setProperty("a", 1);
         for (int i = 0; i <= N; i++) {
-            jsop.append(",\"x").append(i).append("\":{}");
+            builder.child("x" + i);
         }
-        jsop.append('}');
-        microKernel.commit("/", jsop.toString(), null, "test data");
-        return store.getRoot().getChildNode("test");
+        branch.setRoot(builder.getNodeState());
+
+        state = branch.merge();
+    }
+
+    @After
+    public void tearDown() {
+        state = null;
     }
 
     @Test



Mime
View raw message