jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1392271 [2/2] - in /jackrabbit/oak/trunk/oak-mongomk/src: main/java/org/apache/jackrabbit/mongomk/ main/java/org/apache/jackrabbit/mongomk/api/model/ main/java/org/apache/jackrabbit/mongomk/command/ main/java/org/apache/jackrabbit/mongomk/...
Date Mon, 01 Oct 2012 10:40:14 GMT
Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java?rev=1392271&r1=1392270&r2=1392271&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java Mon Oct  1 10:40:12 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.mongomk.command;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
 import java.util.LinkedList;
@@ -45,74 +47,93 @@ import org.junit.Test;
 public class CommitCommandMongoTest extends BaseMongoTest {
 
     @Test
-    @Ignore // FIXME - Implement
-    public void addIntermediataryNodes() throws Exception {
+    public void addNodes() throws Exception {
+        List<Instruction> instructions = new LinkedList<Instruction>();
+        instructions.add(new AddNodeInstructionImpl("/", "a"));
+        instructions.add(new AddNodeInstructionImpl("/a", "b"));
+        instructions.add(new AddNodeInstructionImpl("/a", "c"));
+
+        Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
+                "This is a simple commit", instructions);
+        CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
+        Long revisionId = command.execute();
+
+        Assert.assertNotNull(revisionId);
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
+                "{ \"/#%1$s\" : { \"a#%1$s\" : { \"b#%1$s\" : {} , \"c#%1$s\" : {} } } }", revisionId)));
+
+        MongoAssert.assertCommitExists(commit);
+        MongoAssert.assertCommitContainsAffectedPaths(commit.getRevisionId(), "/", "/a", "/a/b", "/a/c");
+        MongoAssert.assertHeadRevision(1);
+        MongoAssert.assertNextRevision(2);
     }
 
     @Test
-    public void addNewNodesToSameParent() throws Exception {
+    public void addNodesToSameParent() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", "1"));
 
         Commit commit = new CommitImpl("/", "+1 : {}", "This is the 1st commit", instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String firstRevisionId = command.execute();
+        Long firstRevisionId = command.execute();
 
         instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", "2"));
 
         commit = new CommitImpl("/", "+2 : {}", "This is the 2nd commit", instructions);
         command = new CommitCommandMongo(mongoConnection, commit);
-        String secondRevisionId = command.execute();
+        Long secondRevisionId = command.execute();
 
         instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", "3"));
 
         commit = new CommitImpl("/", "+3 : {}", "This is the 3rd commit", instructions);
         command = new CommitCommandMongo(mongoConnection, commit);
-        String thirdRevisionId = command.execute();
+        Long thirdRevisionId = command.execute();
 
-        MongoAssert.assertNodesExist("", NodeBuilder.build(String.format(
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
                 "{ \"/#%3$s\" : { \"1#%1$s\" : { } , \"2#%2$s\" : { } , \"3#%3$s\" : { } } }",
                 firstRevisionId, secondRevisionId, thirdRevisionId)));
     }
 
     @Test
-    public void addNodes() throws Exception {
+    public void addIntermediataryNodes() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", "a"));
         instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        instructions.add(new AddNodeInstructionImpl("/a", "c"));
+        instructions.add(new AddNodeInstructionImpl("/a/b", "c"));
 
-        Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
-                "This is a simple commit", instructions);
+        Commit commit = new CommitImpl("/", "+a : { b : { c: {} }",
+                "Add /a/b/c", instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
+        Long revisionId1 = command.execute();
 
-        Assert.assertNotNull(revisionId);
-        MongoAssert.assertNodesExist("", NodeBuilder.build(String.format(
-                "{ \"/#%1$s\" : { \"a#%1$s\" : { \"b#%1$s\" : {} , \"c#%1$s\" : {} } } }", revisionId)));
+        instructions = new LinkedList<Instruction>();
+        instructions.add(new AddNodeInstructionImpl("/a", "d"));
+        instructions.add(new AddNodeInstructionImpl("/a/b", "e"));
 
-        MongoAssert.assertCommitExists(commit);
-        MongoAssert.assertCommitContainsAffectedPaths(commit.getRevisionId(), "/", "/a", "/a/b", "/a/c");
-        MongoAssert.assertHeadRevision(1);
-        MongoAssert.assertNextRevision(2);
+        commit = new CommitImpl("/", "+a : { b : { e: {} }, d : {} }",
+                "Add /a/d and /a/b/e", instructions);
+        command = new CommitCommandMongo(mongoConnection, commit);
+        Long revisionId2 = command.execute();
+
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
+                "{ \"/#%1$s\" : { \"a#%2$s\" : { \"b#%2$s\" : { \"c#%1$s\" : {}, \"e#%2$s\" : {} }, " +
+                " \"d#%2$s\" : {} } } }", revisionId1, revisionId2)));
     }
 
     @Test
     public void addDuplicateNode() throws Exception {
-        // Add /a and /a/b
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", "a"));
         instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        Commit commit = new CommitImpl("/", "+a : { \"b\" : {} }", "Add /a, /a/b", instructions);
+        Commit commit = new CommitImpl("/", "+a : { \"b\" : {} }", "Add /a/b", instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         command.execute();
 
-        // Add /a/b again
         instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        commit = new CommitImpl("/a", "+b", "Add /a/b", instructions);
+        commit = new CommitImpl("/a", "+b", "Add /a/b again", instructions);
         command = new CommitCommandMongo(mongoConnection, commit);
         try {
             command.execute();
@@ -122,160 +143,118 @@ public class CommitCommandMongoTest exte
     }
 
     @Test
-    public void addNodesAndPropertiesOutOfOrder() throws Exception {
+    public void addNodesAndProperties() throws Exception {
+        SimpleNodeScenario scenario1 = new SimpleNodeScenario(mongoConnection);
+        scenario1.create();
+
         List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddPropertyInstructionImpl("/a", "key1", "value1"));
         instructions.add(new AddNodeInstructionImpl("/", "a"));
+        instructions.add(new AddPropertyInstructionImpl("/a", "key1", "value1"));
         instructions.add(new AddNodeInstructionImpl("/a", "b"));
         instructions.add(new AddPropertyInstructionImpl("/a/b", "key2", "value2"));
-        instructions.add(new AddPropertyInstructionImpl("/a/c", "key3", "value3"));
         instructions.add(new AddNodeInstructionImpl("/a", "c"));
+        instructions.add(new AddPropertyInstructionImpl("/a/c", "key3", "value3"));
 
         Commit commit = new CommitImpl("/",
                 "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }",
                 "This is a simple commit", instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
+        Long revisionId = command.execute();
 
         Assert.assertNotNull(revisionId);
-        MongoAssert
-                .assertNodesExist(
-                        "",
-                        NodeBuilder.build(String
-                                .format("{ \"/#%1$s\" : { \"a#%1$s\" : { \"key1\" : \"value1\", \"b#%1$s\" : { \"key2\" : \"value2\" } , \"c#%1$s\" : { \"key3\" : \"value3\" } } } }",
-                                        revisionId)));
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
+                "{ \"/#%1$s\" : { \"a#%1$s\" : {  \"int\" : 1 , \"key1\" : \"value1\", \"b#%1$s\" : { \"string\" : \"foo\" , \"key2\" : \"value2\" } , \"c#%1$s\" : { \"bool\" : true , \"key3\" : \"value3\" } } } }",
+                revisionId)));
 
         MongoAssert.assertCommitExists(commit);
         MongoAssert.assertCommitContainsAffectedPaths(commit.getRevisionId(), "/", "/a", "/a/b", "/a/c");
-        MongoAssert.assertHeadRevision(1);
-        MongoAssert.assertNextRevision(2);
     }
 
     @Test
-    public void addNodesWhichAlreadyExist() throws Exception {
-        SimpleNodeScenario scenario1 = new SimpleNodeScenario(mongoConnection);
-        scenario1.create();
-
+    public void addNodesAndPropertiesOutOfOrder() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
         instructions.add(new AddPropertyInstructionImpl("/a", "key1", "value1"));
+        instructions.add(new AddNodeInstructionImpl("/", "a"));
         instructions.add(new AddNodeInstructionImpl("/a", "b"));
         instructions.add(new AddPropertyInstructionImpl("/a/b", "key2", "value2"));
-        instructions.add(new AddNodeInstructionImpl("/a", "c"));
         instructions.add(new AddPropertyInstructionImpl("/a/c", "key3", "value3"));
+        instructions.add(new AddNodeInstructionImpl("/a", "c"));
 
         Commit commit = new CommitImpl("/",
                 "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }",
                 "This is a simple commit", instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
+        Long revisionId = command.execute();
 
         Assert.assertNotNull(revisionId);
-        MongoAssert
-                .assertNodesExist(
-                        "",
-                        NodeBuilder.build(String
-                                .format("{ \"/#%1$s\" : { \"a#%1$s\" : {  \"int\" : 1 , \"key1\" : \"value1\", \"b#%1$s\" : { \"string\" : \"foo\" , \"key2\" : \"value2\" } , \"c#%1$s\" : { \"bool\" : true , \"key3\" : \"value3\" } } } }",
-                                        revisionId)));
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
+                "{ \"/#%1$s\" : { \"a#%1$s\" : { \"key1\" : \"value1\", \"b#%1$s\" : { \"key2\" : \"value2\" } , \"c#%1$s\" : { \"key3\" : \"value3\" } } } }",
+                revisionId)));
 
         MongoAssert.assertCommitExists(commit);
-        // MongoAssert.assertCommitContainsAffectedPaths(commit.getRevisionId(), "/a", "/a/b", "/a/c"); TODO think about
-        // whether / should really be included since it already contained /a
         MongoAssert.assertCommitContainsAffectedPaths(commit.getRevisionId(), "/", "/a", "/a/b", "/a/c");
+        MongoAssert.assertHeadRevision(1);
+        MongoAssert.assertNextRevision(2);
+    }
+
+    @Test
+    @Ignore
+    // FIXME - This currently fails due to some limit in property sizes in Mongo
+    // which affects path property.
+    public void bigCommit() throws Exception {
+        String path = "/";
+        String baseNodeName = "test";
+        int numberOfCommits = 1000;
+
+        List<Instruction> instructions = new LinkedList<Instruction>();
+        for (int i = 0; i < numberOfCommits; i++) {
+            instructions.clear();
+            instructions.add(new AddNodeInstructionImpl(path, baseNodeName + i));
+            Commit commit = new CommitImpl(path, "+" + baseNodeName + i + " : {}",
+                    "Add node n" + i, instructions);
+            CommitCommandMongo command = new CommitCommandMongo(
+                    mongoConnection, commit);
+            command.execute();
+            if (!PathUtils.denotesRoot(path)) {
+                path += "/";
+            }
+            path += baseNodeName + i;
+        }
     }
 
     @Test
     public void commitAndMergeNodes() throws Exception {
         SimpleNodeScenario scenario1 = new SimpleNodeScenario(mongoConnection);
-        String firstRevisionId = scenario1.create();
-        String secondRevisionId = scenario1.update_A_and_add_D_and_E();
+        Long firstRevisionId = scenario1.create();
+        Long secondRevisionId = scenario1.update_A_and_add_D_and_E();
 
         SimpleNodeScenario scenario2 = new SimpleNodeScenario(mongoConnection);
-        String thirdRevisionId = scenario2.create();
+        Long thirdRevisionId = scenario2.create();
+
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
+                "{ \"/#%1$s\" : { \"a#%1$s\" : { \"int\" : 1 , \"b#%1$s\" : { \"string\" : \"foo\" } , \"c#%1$s\" : { \"bool\" : true } } } }",
+                firstRevisionId)));
+
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
+                "{ \"/#%1$s\" : { \"a#%2$s\" : { \"int\" : 1 , \"double\" : 0.123 , \"b#%2$s\" : { \"string\" : \"foo\" , \"e#%2$s\" : { \"array\" : [ 123, null, 123.456, \"for:bar\", true ] } } , \"c#%1$s\" : { \"bool\" : true }, \"d#%2$s\" : { \"null\" : null } } } }",
+                firstRevisionId, secondRevisionId)));
 
-        MongoAssert
-                .assertNodesExist(
-                        "",
-                        NodeBuilder.build(String
-                                .format("{ \"/#%1$s\" : { \"a#%1$s\" : { \"int\" : 1 , \"b#%1$s\" : { \"string\" : \"foo\" } , \"c#%1$s\" : { \"bool\" : true } } } }",
-                                        firstRevisionId)));
-        MongoAssert
-                .assertNodesExist(
-                        "",
-                        NodeBuilder.build(String
-                                .format("{ \"/#%1$s\" : { \"a#%2$s\" : { \"int\" : 1 , \"double\" : 0.123 , \"b#%2$s\" : { \"string\" : \"foo\" , \"e#%2$s\" : { \"array\" : [ 123, null, 123.456, \"for:bar\", true ] } } , \"c#%1$s\" : { \"bool\" : true }, \"d#%2$s\" : { \"null\" : null } } } }",
-                                        firstRevisionId, secondRevisionId)));
-        MongoAssert
-                .assertNodesExist(
-                        "",
-                        NodeBuilder.build(String
-                                .format("{ \"/#%3$s\" : { \"a#%3$s\" : { \"int\" : 1 , \"double\" : 0.123 , \"b#%3$s\" : { \"string\" : \"foo\" , \"e#%2$s\" : { \"array\" : [ 123, null, 123.456, \"for:bar\", true ] } } , \"c#%3$s\" : { \"bool\" : true }, \"d#%2$s\" : { \"null\" : null } } } }",
-                                        firstRevisionId, secondRevisionId,
-                                        thirdRevisionId)));
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
+                "{ \"/#%3$s\" : { \"a#%3$s\" : { \"int\" : 1 , \"double\" : 0.123 , \"b#%3$s\" : { \"string\" : \"foo\" , \"e#%2$s\" : { \"array\" : [ 123, null, 123.456, \"for:bar\", true ] } } , \"c#%3$s\" : { \"bool\" : true }, \"d#%2$s\" : { \"null\" : null } } } }",
+                firstRevisionId, secondRevisionId, thirdRevisionId)));
     }
 
     @Test
     public void commitContainsAllAffectedNodes() throws Exception {
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
-        String firstRevisionId = scenario.create();
-        String secondRevisionId = scenario.update_A_and_add_D_and_E();
+        Long firstRevisionId = scenario.create();
+        Long secondRevisionId = scenario.update_A_and_add_D_and_E();
 
         MongoAssert.assertCommitContainsAffectedPaths(firstRevisionId, "/", "/a", "/a/b", "/a/c");
         MongoAssert.assertCommitContainsAffectedPaths(secondRevisionId, "/a", "/a/b", "/a/d", "/a/b/e");
     }
 
     @Test
-    public void removeNode() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-        instructions.add(new AddNodeInstructionImpl("/a", "c"));
-
-        Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
-                "This is a simple commit", instructions);
-        CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
-        Assert.assertNotNull(revisionId);
-
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new RemoveNodeInstructionImpl("/", "a"));
-
-        commit = new CommitImpl("/", "-a", "This is a simple commit", instructions);
-        command = new CommitCommandMongo(mongoConnection, commit);
-        revisionId = command.execute();
-        Assert.assertNotNull(revisionId);
-
-        MongoAssert.assertNodesExist("",
-                NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }", revisionId)));
-
-        MongoAssert.assertCommitExists(commit);
-        MongoAssert.assertCommitContainsAffectedPaths(commit.getRevisionId(), "/");
-    }
-
-    @Test
-    public void removeNonExistentNode() throws Exception {
-        List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("/", "a"));
-        instructions.add(new AddNodeInstructionImpl("/a", "b"));
-
-        Commit commit = new CommitImpl("/", "+a : { b : {}  }", "Add nodes", instructions);
-        CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        command.execute();
-
-        instructions = new LinkedList<Instruction>();
-        instructions.add(new RemoveNodeInstructionImpl("/a", "c"));
-
-        commit = new CommitImpl("/a", "-c", "Non-existent node delete", instructions);
-        command = new CommitCommandMongo(mongoConnection, commit);
-        try {
-            command.execute();
-            fail("Exception expected");
-        } catch (Exception expected) {
-
-        }
-    }
-
-    @Test
     public void existingParentContainsChildren() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", "a"));
@@ -285,19 +264,19 @@ public class CommitCommandMongoTest exte
         Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
                 "This is a simple commit", instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
+        Long revisionId = command.execute();
 
-        Assert.assertNotNull(revisionId);
-        MongoAssert.assertNodesExist("", NodeBuilder.build(String.format(
+        assertNotNull(revisionId);
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
                 "{ \"/#%1$s\" : { \"a#%1$s\" : {}, \"b#%1$s\" : {} , \"c#%1$s\" : {} } }", revisionId)));
 
         GetNodesCommandMongo command2 = new GetNodesCommandMongo(mongoConnection, "/", revisionId, 0);
         Node rootOfPath = command2.execute();
-        Assert.assertEquals(3, rootOfPath.getChildCount());
+        assertEquals(3, rootOfPath.getChildCount());
     }
 
     @Test
-    public void mergePropertiesAndChildren_noneExistedAndNewAdded() throws Exception {
+    public void mergePropertiesAndChildrenNoneExistedAndNewAdded() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", "a"));
         instructions.add(new AddPropertyInstructionImpl("/a", "key1", "value1"));
@@ -308,19 +287,16 @@ public class CommitCommandMongoTest exte
                 "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }",
                 "This is a simple commit", instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
+        Long revisionId = command.execute();
 
-        MongoAssert.assertNodesExist("", NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }", "0")));
-        MongoAssert
-                .assertNodesExist(
-                        "",
-                        NodeBuilder.build(String
-                                .format("{ \"/#%1$s\" : { \"a#%1$s\" : { \"key1\" : \"value1\", \"key2\" : \"value2\", \"key3\" : \"value3\" } } }",
-                                        revisionId)));
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }", "0")));
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
+                "{ \"/#%1$s\" : { \"a#%1$s\" : { \"key1\" : \"value1\", \"key2\" : \"value2\", \"key3\" : \"value3\" } } }",
+                revisionId)));
     }
 
     @Test
-    public void mergePropertiesAndChildren_someExistedAndNewAdded() throws Exception {
+    public void mergePropertiesAndChildrenSomeExistedAndNewAdded() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", "a"));
         instructions.add(new AddPropertyInstructionImpl("/a", "existed_key1", "value1"));
@@ -331,7 +307,7 @@ public class CommitCommandMongoTest exte
                 "+a : { \"existed_key1\" : \"value1\" , \"existed_key2\" : \"value2\" , \"existed_key3\" : \"value3\" }",
                 "This is a simple commit", instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
+        Long revisionId = command.execute();
 
         instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", "a"));
@@ -345,13 +321,9 @@ public class CommitCommandMongoTest exte
         command = new CommitCommandMongo(mongoConnection, commit);
         revisionId = command.execute();
 
-        MongoAssert.assertNodesExist("", NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }", "0")));
-        MongoAssert
-                .assertNodesExist(
-                        "",
-                        NodeBuilder.build(String
-                                .format("{ \"/#%1$s\" : { \"a#%1$s\" : { \"existed_key1\" : \"value1\", \"existed_key2\" : \"value2\", \"existed_key3\" : \"value3\", \"key1\" : \"value1\", \"key2\" : \"value2\", \"key3\" : \"value3\" } } }",
-                                        revisionId)));
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }", "0")));
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format("{ \"/#%1$s\" : { \"a#%1$s\" : { \"existed_key1\" : \"value1\", \"existed_key2\" : \"value2\", \"existed_key3\" : \"value3\", \"key1\" : \"value1\", \"key2\" : \"value2\", \"key3\" : \"value3\" } } }",
+                revisionId)));
     }
 
     @Test
@@ -364,7 +336,7 @@ public class CommitCommandMongoTest exte
         Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
                 "This is a simple commit", instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String firstRevisionId = command.execute();
+        Long firstRevisionId = command.execute();
 
         instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/a", "d"));
@@ -372,7 +344,7 @@ public class CommitCommandMongoTest exte
 
         commit = new CommitImpl("/a", "+d: {} \n+e : {}", "This is a simple commit", instructions);
         command = new CommitCommandMongo(mongoConnection, commit);
-        String secondRevisionId = command.execute();
+        Long secondRevisionId = command.execute();
 
         MongoAssert.assertNodeRevisionId("/", firstRevisionId, true);
         MongoAssert.assertNodeRevisionId("/a", firstRevisionId, true);
@@ -390,42 +362,69 @@ public class CommitCommandMongoTest exte
     }
 
     @Test
-    public void rootNodeHasEmptyRootPath() throws Exception {
+    public void removeNode() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
-        instructions.add(new AddNodeInstructionImpl("", "/"));
+        instructions.add(new AddNodeInstructionImpl("/", "a"));
+        instructions.add(new AddNodeInstructionImpl("/a", "b"));
+        instructions.add(new AddNodeInstructionImpl("/a", "c"));
 
-        Commit commit = new CommitImpl(MongoUtil.INITIAL_COMMIT_PATH, MongoUtil.INITIAL_COMMIT_DIFF,
-                MongoUtil.INITIAL_COMMIT_MESSAGE, instructions);
+        Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
+                "Add a and its children", instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
-        Assert.assertNotNull(revisionId);
+        Long revisionId = command.execute();
+        assertNotNull(revisionId);
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format(
+                "{ \"/#%1$s\" : { \"a#%1$s\" : { \"b#%1$s\" : {} , \"c#%1$s\" : {} } } }", revisionId)));
 
-        Node expected = NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }", revisionId));
-        MongoAssert.assertNodesExist(MongoUtil.INITIAL_COMMIT_PATH, expected);
+        instructions = new LinkedList<Instruction>();
+        instructions.add(new RemoveNodeInstructionImpl("/", "a"));
+
+        commit = new CommitImpl("/", "-a", "Remove a", instructions);
+        command = new CommitCommandMongo(mongoConnection, commit);
+        revisionId = command.execute();
+        assertNotNull(revisionId);
+        MongoAssert.assertNodesExist(NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }",
+                revisionId)));
+
+        MongoAssert.assertCommitExists(commit);
+        MongoAssert.assertCommitContainsAffectedPaths(commit.getRevisionId(), "/");
     }
 
     @Test
-    @Ignore
-    // FIXME - This currently fails due to some limit in property sizes in Mongo
-    // which affects path property.
-    public void bigCommit() throws Exception {
-        String path = "/";
-        String baseNodeName = "test";
-        int numberOfCommits = 1000;
-
+    public void removeNonExistentNode() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
-        for (int i = 0; i < numberOfCommits; i++) {
-            instructions.clear();
-            instructions.add(new AddNodeInstructionImpl(path, baseNodeName + i));
-            Commit commit = new CommitImpl(path, "+" + baseNodeName + i + " : {}",
-                    "Add node n" + i, instructions);
-            CommitCommandMongo command = new CommitCommandMongo(
-                    mongoConnection, commit);
+        instructions.add(new AddNodeInstructionImpl("/", "a"));
+        instructions.add(new AddNodeInstructionImpl("/a", "b"));
+
+        Commit commit = new CommitImpl("/", "+a : { b : {}  }", "Add nodes", instructions);
+        CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
+        command.execute();
+
+        instructions = new LinkedList<Instruction>();
+        instructions.add(new RemoveNodeInstructionImpl("/a", "c"));
+
+        commit = new CommitImpl("/a", "-c", "Non-existent node delete", instructions);
+        command = new CommitCommandMongo(mongoConnection, commit);
+        try {
             command.execute();
-            if (!PathUtils.denotesRoot(path)) {
-                path += "/";
-            }
-            path += baseNodeName + i;
+            fail("Exception expected");
+        } catch (Exception expected) {
+
         }
     }
-}
+
+    @Test
+    public void rootNodeHasEmptyRootPath() throws Exception {
+        List<Instruction> instructions = new LinkedList<Instruction>();
+        instructions.add(new AddNodeInstructionImpl("", "/"));
+
+        Commit commit = new CommitImpl(MongoUtil.INITIAL_COMMIT_PATH, MongoUtil.INITIAL_COMMIT_DIFF,
+                MongoUtil.INITIAL_COMMIT_MESSAGE, instructions);
+        CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
+        Long revisionId = command.execute();
+        assertNotNull(revisionId);
+
+        Node expected = NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }", revisionId));
+        MongoAssert.assertNodesExist(expected);
+    }
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/ConcurrentCommitCommandMongoTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/ConcurrentCommitCommandMongoTest.java?rev=1392271&r1=1392270&r2=1392271&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/ConcurrentCommitCommandMongoTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/ConcurrentCommitCommandMongoTest.java Mon Oct  1 10:40:12 2012
@@ -75,7 +75,7 @@ public class ConcurrentCommitCommandMong
         // execute the commands
         final CommandExecutor commandExecutor = new CommandExecutorImpl();
         ExecutorService executorService = Executors.newFixedThreadPool(numOfConcurrentThreads);
-        final List<String> revisionIds = new LinkedList<String>();
+        final List<Long> revisionIds = new LinkedList<Long>();
         for (int i = 0; i < numOfConcurrentThreads; ++i) {
             final CommitCommandMongo command = commands.get(i);
             Runnable runnable = new Runnable() {
@@ -83,7 +83,7 @@ public class ConcurrentCommitCommandMong
                 @Override
                 public void run() {
                     try {
-                        String revisionId = commandExecutor.execute(command);
+                        Long revisionId = commandExecutor.execute(command);
                         revisionIds.add(revisionId);
                     } catch (Exception e) {
                         revisionIds.add(null);
@@ -101,18 +101,17 @@ public class ConcurrentCommitCommandMong
             }
         } while (revisionIds.size() < numOfConcurrentThreads);
 
-        // verify the result by sorting the revision ids and verifying that all children are contained in the next
-        // revision
-        Collections.sort(revisionIds, new Comparator<String>() {
+        // Verify the result by sorting the revision ids and verifying that all
+        // children are contained in the next revision
+        Collections.sort(revisionIds, new Comparator<Long>() {
             @Override
-            public int compare(String o1, String o2) {
-                return Long.valueOf(o1).compareTo(Long.valueOf(o2));
+            public int compare(Long o1, Long o2) {
+                return o1.compareTo(o2);
             }
         });
         List<String> lastChildren = new LinkedList<String>();
         for (int i = 0; i < numOfConcurrentThreads; ++i) {
-            String revisionId = revisionIds.get(i);
-
+            Long revisionId = revisionIds.get(i);
             GetNodesCommandMongo command2 = new GetNodesCommandMongo(mongoConnection, "/", revisionId, 0);
             Node root = command2.execute();
             Set<Node> children = root.getChildren();

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/GetHeadRevisionCommandMongoTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/GetHeadRevisionCommandMongoTest.java?rev=1392271&r1=1392270&r2=1392271&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/GetHeadRevisionCommandMongoTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/GetHeadRevisionCommandMongoTest.java Mon Oct  1 10:40:12 2012
@@ -31,13 +31,13 @@ public class GetHeadRevisionCommandMongo
     @Test
     public void testGeadHeadRevisionSimple() throws Exception {
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
-        String revisionId = scenario.create();
+        Long revisionId = scenario.create();
 
         GetHeadRevisionCommandMongo command = new GetHeadRevisionCommandMongo(mongoConnection);
-        String revisionId2 = command.execute();
-        assertTrue(revisionId.equals(revisionId2));
+        Long revisionId2 = command.execute();
+        assertTrue(revisionId == revisionId2);
 
         scenario.delete_A();
-        String revisionId3 = command.execute();
-        assertFalse(revisionId3.equals(revisionId2));
+        Long revisionId3 = command.execute();
+        assertFalse(revisionId3 == revisionId2);
     }}

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/GetNodesCommandMongoTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/GetNodesCommandMongoTest.java?rev=1392271&r1=1392270&r2=1392271&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/GetNodesCommandMongoTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/GetNodesCommandMongoTest.java Mon Oct  1 10:40:12 2012
@@ -33,8 +33,8 @@ public class GetNodesCommandMongoTest ex
     @Test
     public void getNodesSimple() throws Exception {
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
-        String firstRevisionId = scenario.create();
-        String secondRevisionId = scenario.update_A_and_add_D_and_E();
+        Long firstRevisionId = scenario.create();
+        Long secondRevisionId = scenario.update_A_and_add_D_and_E();
 
         GetNodesCommandMongo command = new GetNodesCommandMongo(mongoConnection, "/",
                 firstRevisionId, 0);
@@ -53,8 +53,8 @@ public class GetNodesCommandMongoTest ex
     @Test
     public void getNodesDepthLimited() throws Exception {
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
-        String firstRevisionId = scenario.create();
-        String secondRevisionId = scenario.update_A_and_add_D_and_E();
+        Long firstRevisionId = scenario.create();
+        Long secondRevisionId = scenario.update_A_and_add_D_and_E();
 
         GetNodesCommandMongo command = new GetNodesCommandMongo(mongoConnection, "/", firstRevisionId, 1);
         Node actual = command.execute();
@@ -104,8 +104,8 @@ public class GetNodesCommandMongoTest ex
     @Test
     public void getNodesDepthUnlimited() throws Exception {
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
-        String firstRevisionId = scenario.create();
-        String secondRevisionId = scenario.update_A_and_add_D_and_E();
+        Long firstRevisionId = scenario.create();
+        Long secondRevisionId = scenario.update_A_and_add_D_and_E();
 
         GetNodesCommandMongo command = new GetNodesCommandMongo(mongoConnection, "/", firstRevisionId, -1);
         Node actual = command.execute();
@@ -125,7 +125,7 @@ public class GetNodesCommandMongoTest ex
     @Test
     public void getNodesAfterDeletion() throws Exception {
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
-        String revisionId = scenario.create();
+        Long revisionId = scenario.create();
         revisionId = scenario.delete_A();
 
         GetNodesCommandMongo command = new GetNodesCommandMongo(mongoConnection, "/", revisionId, -1);
@@ -140,7 +140,8 @@ public class GetNodesCommandMongoTest ex
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
         scenario.create();
 
-        GetNodesCommandMongo command = new GetNodesCommandMongo(mongoConnection, "/", String.valueOf(Long.MAX_VALUE), -1);
+        GetNodesCommandMongo command = new GetNodesCommandMongo(mongoConnection,
+                "/", Long.MAX_VALUE, -1);
         try {
             command.execute();
             fail("Exception expected");

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongoTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongoTest.java?rev=1392271&r1=1392270&r2=1392271&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongoTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongoTest.java Mon Oct  1 10:40:12 2012
@@ -38,7 +38,7 @@ public class NodeExistsCommandMongoTest 
     @Test
     public void simple() throws Exception {
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
-        String revisionId = scenario.create();
+        Long revisionId = scenario.create();
 
         NodeExistsCommandMongo command = new NodeExistsCommandMongo(
                 mongoConnection, "/a", revisionId);
@@ -85,7 +85,7 @@ public class NodeExistsCommandMongoTest 
         scenario.create();
 
         NodeExistsCommandMongo command = new NodeExistsCommandMongo(
-                mongoConnection, "/a", "123456789");
+                mongoConnection, "/a", 123456789L);
         try {
             command.execute();
             fail("Expected: Invalid revision id exception");
@@ -168,8 +168,8 @@ public class NodeExistsCommandMongoTest 
     @Test
     public void existsInOldRevNotInNewRev() throws Exception {
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
-        String rev1 = scenario.create();
-        String rev2 = scenario.delete_A();
+        Long rev1 = scenario.create();
+        Long rev2 = scenario.delete_A();
 
         NodeExistsCommandMongo command = new NodeExistsCommandMongo(
                 mongoConnection, "/a", rev1);

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/NodeAssert.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/NodeAssert.java?rev=1392271&r1=1392270&r2=1392271&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/NodeAssert.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/NodeAssert.java Mon Oct  1 10:40:12 2012
@@ -81,8 +81,8 @@ public class NodeAssert {
         Assert.assertEquals(expected.getName(), actual.getName());
         Assert.assertEquals(expected.getPath(), actual.getPath());
 
-        String expectedRevisionId = expected.getRevisionId();
-        String actualRevisionId = actual.getRevisionId();
+        Long expectedRevisionId = expected.getRevisionId();
+        Long actualRevisionId = actual.getRevisionId();
 
         if (expectedRevisionId == null) {
             Assert.assertNull(actualRevisionId);

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/builder/NodeBuilderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/builder/NodeBuilderTest.java?rev=1392271&r1=1392270&r2=1392271&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/builder/NodeBuilderTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/builder/NodeBuilderTest.java Mon Oct  1 10:40:12 2012
@@ -48,13 +48,13 @@ public class NodeBuilderTest {
         Node node = NodeBuilder.build(json);
 
         Node node_c = new NodeImpl("/a/c");
-        node_c.setRevisionId("2");
+        node_c.setRevisionId(2L);
         Node node_b = new NodeImpl("/a/b");
-        node_b.setRevisionId("2");
+        node_b.setRevisionId(2L);
         Node node_a = new NodeImpl("/a", new Node[] { node_b, node_c });
-        node_a.setRevisionId("1");
+        node_a.setRevisionId(1L);
         Node node_root = new NodeImpl("/", new Node[] { node_a });
-        node_root.setRevisionId("1");
+        node_root.setRevisionId(1L);
 
         NodeAssert.assertDeepEquals(node, node_root);
     }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQueryTest.java?rev=1392271&r1=1392270&r2=1392271&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQueryTest.java Mon Oct  1 10:40:12 2012
@@ -32,7 +32,6 @@ import org.apache.jackrabbit.mongomk.imp
 import org.apache.jackrabbit.mongomk.model.CommitMongo;
 import org.apache.jackrabbit.mongomk.model.NodeMongo;
 import org.apache.jackrabbit.mongomk.scenario.SimpleNodeScenario;
-import org.apache.jackrabbit.mongomk.util.MongoUtil;
 import org.junit.Test;
 
 import com.mongodb.BasicDBObject;
@@ -44,12 +43,12 @@ public class FetchNodesByPathAndDepthQue
 
     @Test
     public void fetchWithInvalidFirstRevision() throws Exception {
-        String revisionId1 = addNode("a");
-        String revisionId2 = addNode("b");
-        String revisionId3 = addNode("c");
+        Long revisionId1 = addNode("a");
+        Long revisionId2 = addNode("b");
+        Long revisionId3 = addNode("c");
 
         invalidateCommit(revisionId1);
-        updateBaseRevisionId(revisionId2, "0");
+        updateBaseRevisionId(revisionId2, 0L);
 
         FetchNodesByPathAndDepthQuery query = new FetchNodesByPathAndDepthQuery(mongoConnection,
                 "/", revisionId3, -1);
@@ -63,9 +62,9 @@ public class FetchNodesByPathAndDepthQue
 
     @Test
     public void fetchWithInvalidLastRevision() throws Exception {
-        String revisionId1 = addNode("a");
-        String revisionId2 = addNode("b");
-        String revisionId3 = addNode("c");
+        Long revisionId1 = addNode("a");
+        Long revisionId2 = addNode("b");
+        Long revisionId3 = addNode("c");
 
         invalidateCommit(revisionId3);
 
@@ -81,9 +80,9 @@ public class FetchNodesByPathAndDepthQue
 
     @Test
     public void fetchWithInvalidMiddleRevision() throws Exception {
-        String revisionId1 = addNode("a");
-        String revisionId2 = addNode("b");
-        String revisionId3 = addNode("c");
+        Long revisionId1 = addNode("a");
+        Long revisionId2 = addNode("b");
+        Long revisionId3 = addNode("c");
 
         invalidateCommit(revisionId2);
         updateBaseRevisionId(revisionId3, revisionId1);
@@ -100,11 +99,11 @@ public class FetchNodesByPathAndDepthQue
     @Test
     public void simpleFetchRootAndAllDepths() throws Exception {
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
-        String firstRevisionId = scenario.create();
-        String secondRevisionId = scenario.update_A_and_add_D_and_E();
+        Long firstRevisionId = scenario.create();
+        Long secondRevisionId = scenario.update_A_and_add_D_and_E();
 
-        FetchNodesByPathAndDepthQuery query = new FetchNodesByPathAndDepthQuery(mongoConnection, "/", firstRevisionId,
-                0);
+        FetchNodesByPathAndDepthQuery query = new FetchNodesByPathAndDepthQuery(mongoConnection,
+                "/", firstRevisionId, 0);
         List<NodeMongo> result = query.execute();
         List<Node> actuals = NodeMongo.toNode(result);
         Node expected = NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }", firstRevisionId));
@@ -176,32 +175,30 @@ public class FetchNodesByPathAndDepthQue
         NodeAssert.assertEquals(expecteds, actuals);
     }
 
-    private String addNode(String nodeName) throws Exception {
+    private Long addNode(String nodeName) throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", nodeName));
         Commit commit = new CommitImpl("/", "+" + nodeName, "Add /" + nodeName, instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
-        return revisionId;
+        return command.execute();
     }
 
-    private void invalidateCommit(String revisionId) {
+    private void invalidateCommit(Long revisionId) {
         DBCollection commitCollection = mongoConnection.getCommitCollection();
         DBObject query = QueryBuilder.start(CommitMongo.KEY_REVISION_ID)
-                .is(MongoUtil.toMongoRepresentation(revisionId)).get();
+                .is(revisionId).get();
         DBObject update = new BasicDBObject();
         update.put("$set", new BasicDBObject(CommitMongo.KEY_FAILED, Boolean.TRUE));
         commitCollection.update(query, update);
     }
 
-    private void updateBaseRevisionId(String revisionId2, String baseRevisionId) {
+    private void updateBaseRevisionId(Long revisionId2, Long baseRevisionId) {
         DBCollection commitCollection = mongoConnection.getCommitCollection();
         DBObject query = QueryBuilder.start(CommitMongo.KEY_REVISION_ID)
-                .is(MongoUtil.toMongoRepresentation(revisionId2))
+                .is(revisionId2)
                 .get();
         DBObject update = new BasicDBObject("$set",
-                new BasicDBObject(CommitMongo.KEY_BASE_REVISION_ID,
-                        MongoUtil.toMongoRepresentation(baseRevisionId)));
+                new BasicDBObject(CommitMongo.KEY_BASE_REVISION_ID, baseRevisionId));
         commitCollection.update(query, update);
     }
 }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQueryTest.java?rev=1392271&r1=1392270&r2=1392271&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQueryTest.java Mon Oct  1 10:40:12 2012
@@ -49,12 +49,12 @@ public class FetchNodesForRevisionQueryT
 
     @Test
     public void fetchWithInvalidFirstRevision() throws Exception {
-        String revisionId1 = addNode("a");
-        String revisionId2 = addNode("b");
-        String revisionId3 = addNode("c");
+        Long revisionId1 = addNode("a");
+        Long revisionId2 = addNode("b");
+        Long revisionId3 = addNode("c");
 
         invalidateCommit(revisionId1);
-        updateBaseRevisionId(revisionId2, "0");
+        updateBaseRevisionId(revisionId2, 0L);
 
         FetchNodesForRevisionQuery query = new FetchNodesForRevisionQuery(mongoConnection,
                 new String[] { "/", "/a", "/b", "/c", "not_existing" }, revisionId3);
@@ -68,9 +68,9 @@ public class FetchNodesForRevisionQueryT
 
     @Test
     public void fetchWithInvalidLastRevision() throws Exception {
-        String revisionId1 = addNode("a");
-        String revisionId2 = addNode("b");
-        String revisionId3 = addNode("c");
+        Long revisionId1 = addNode("a");
+        Long revisionId2 = addNode("b");
+        Long revisionId3 = addNode("c");
 
         invalidateCommit(revisionId3);
 
@@ -85,9 +85,9 @@ public class FetchNodesForRevisionQueryT
 
     @Test
     public void fetchWithInvalidMiddleRevision() throws Exception {
-        String revisionId1 = addNode("a");
-        String revisionId2 = addNode("b");
-        String revisionId3 = addNode("c");
+        Long revisionId1 = addNode("a");
+        Long revisionId2 = addNode("b");
+        Long revisionId3 = addNode("c");
 
         invalidateCommit(revisionId2);
         updateBaseRevisionId(revisionId3, revisionId1);
@@ -104,7 +104,7 @@ public class FetchNodesForRevisionQueryT
     @Test
     public void fetchWithOneRevision() throws Exception {
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
-        String revisionId = scenario.create();
+        Long revisionId = scenario.create();
 
         FetchNodesForRevisionQuery query = new FetchNodesForRevisionQuery(mongoConnection, new String[] { "/", "/a",
                 "/a/b", "/a/c", "not_existing" }, revisionId);
@@ -129,11 +129,12 @@ public class FetchNodesForRevisionQueryT
     @Test
     public void fetchWithTwoRevisions() throws Exception {
         SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
-        String firstRevisionId = scenario.create();
-        String secondRevisionId = scenario.update_A_and_add_D_and_E();
+        Long firstRevisionId = scenario.create();
+        Long secondRevisionId = scenario.update_A_and_add_D_and_E();
 
-        FetchNodesForRevisionQuery query = new FetchNodesForRevisionQuery(mongoConnection, new String[] { "/", "/a",
-                "/a/b", "/a/c", "/a/d", "/a/b/e", "not_existing" }, firstRevisionId);
+        FetchNodesForRevisionQuery query = new FetchNodesForRevisionQuery(mongoConnection,
+                new String[] { "/", "/a", "/a/b", "/a/c", "/a/d", "/a/b/e", "not_existing" },
+                firstRevisionId);
         List<NodeMongo> nodeMongos = query.execute();
         List<Node> actuals = NodeMongo.toNode(nodeMongos);
         Node expected = NodeBuilder
@@ -155,32 +156,30 @@ public class FetchNodesForRevisionQueryT
         NodeAssert.assertEquals(expecteds, actuals);
     }
 
-    private String addNode(String nodeName) throws Exception {
+    private Long addNode(String nodeName) throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", nodeName));
         Commit commit = new CommitImpl("/", "+" + nodeName, "Add /" + nodeName, instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
-        return revisionId;
+        return command.execute();
     }
 
-    private void invalidateCommit(String revisionId) {
+    private void invalidateCommit(Long revisionId) {
         DBCollection commitCollection = mongoConnection.getCommitCollection();
         DBObject query = QueryBuilder.start(CommitMongo.KEY_REVISION_ID)
-                .is(MongoUtil.toMongoRepresentation(revisionId)).get();
+                .is(revisionId).get();
         DBObject update = new BasicDBObject();
         update.put("$set", new BasicDBObject(CommitMongo.KEY_FAILED, Boolean.TRUE));
         commitCollection.update(query, update);
     }
 
-    private void updateBaseRevisionId(String revisionId2, String baseRevisionId) {
+    private void updateBaseRevisionId(Long revisionId2, Long baseRevisionId) {
         DBCollection commitCollection = mongoConnection.getCommitCollection();
         DBObject query = QueryBuilder.start(CommitMongo.KEY_REVISION_ID)
-                .is(MongoUtil.toMongoRepresentation(revisionId2))
+                .is(revisionId2)
                 .get();
         DBObject update = new BasicDBObject("$set",
-                new BasicDBObject(CommitMongo.KEY_BASE_REVISION_ID,
-                        MongoUtil.toMongoRepresentation(baseRevisionId)));
+                new BasicDBObject(CommitMongo.KEY_BASE_REVISION_ID, baseRevisionId));
         commitCollection.update(query, update);
     }
 }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQueryTest.java?rev=1392271&r1=1392270&r2=1392271&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQueryTest.java Mon Oct  1 10:40:12 2012
@@ -36,7 +36,7 @@ public class FetchValidCommitsQueryTest 
     @Test
     public void simple() throws Exception {
         FetchValidCommitsQuery query = new FetchValidCommitsQuery(mongoConnection,
-                String.valueOf(Integer.MAX_VALUE) /*maxRevisionId*/);
+                Long.MAX_VALUE);
         List<CommitMongo> commits = query.execute();
         assertEquals(MIN_COMMITS, commits.size());
 
@@ -54,7 +54,7 @@ public class FetchValidCommitsQueryTest 
     @Test
     public void revisionId() throws Exception {
         FetchValidCommitsQuery query = new FetchValidCommitsQuery(mongoConnection,
-                String.valueOf(Integer.MAX_VALUE) /*maxRevisionId*/);
+                Long.MAX_VALUE);
         List<CommitMongo> commits = query.execute();
         CommitMongo commit0 = commits.get(0);
 
@@ -74,7 +74,7 @@ public class FetchValidCommitsQueryTest 
     @Test
     public void time() throws Exception {
         FetchValidCommitsQuery query = new FetchValidCommitsQuery(mongoConnection,
-                String.valueOf(Integer.MAX_VALUE) /*maxRevisionId*/);
+                Long.MAX_VALUE);
         List<CommitMongo> commits = query.execute();
         CommitMongo commit0 = commits.get(0);
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/scenario/SimpleNodeScenario.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/scenario/SimpleNodeScenario.java?rev=1392271&r1=1392270&r2=1392271&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/scenario/SimpleNodeScenario.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/scenario/SimpleNodeScenario.java Mon Oct  1 10:40:12 2012
@@ -19,10 +19,10 @@ package org.apache.jackrabbit.mongomk.sc
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.jackrabbit.mongomk.MongoConnection;
 import org.apache.jackrabbit.mongomk.api.model.Commit;
 import org.apache.jackrabbit.mongomk.api.model.Instruction;
 import org.apache.jackrabbit.mongomk.command.CommitCommandMongo;
+import org.apache.jackrabbit.mongomk.impl.MongoConnection;
 import org.apache.jackrabbit.mongomk.impl.model.AddNodeInstructionImpl;
 import org.apache.jackrabbit.mongomk.impl.model.AddPropertyInstructionImpl;
 import org.apache.jackrabbit.mongomk.impl.model.CommitImpl;
@@ -33,15 +33,14 @@ import org.apache.jackrabbit.mongomk.imp
  *
  * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
  */
-public class SimpleNodeScenario { // TODO this should be refactored to use class rules
+public class SimpleNodeScenario {
 
     private final MongoConnection mongoConnection;
 
     /**
      * Constructs a new {@code SimpleNodeScenario}.
      *
-     * @param mongoConnection
-     *            The {@link MongoConnection}.
+     * @param mongoConnection The {@link MongoConnection}.
      */
     public SimpleNodeScenario(MongoConnection mongoConnection) {
         this.mongoConnection = mongoConnection;
@@ -55,10 +54,9 @@ public class SimpleNodeScenario { // TOD
      * </pre>
      *
      * @return The {@link RevisionId}.
-     * @throws Exception
-     *             If an error occurred.
+     * @throws Exception If an error occurred.
      */
-    public String create() throws Exception {
+    public Long create() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", "a"));
         instructions.add(new AddNodeInstructionImpl("/a", "b"));
@@ -71,13 +69,11 @@ public class SimpleNodeScenario { // TOD
                 "+a : { \"int\" : 1 , \"b\" : { \"string\" : \"foo\" } , \"c\" : { \"bool\" : true } } }",
                 "This is the simple node scenario with nodes /, /a, /a/b, /a/c", instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
-
-        return revisionId;
+        return command.execute();
     }
 
-    public String addChildrenToA(int count) throws Exception {
-        String revisionId = null;
+    public Long addChildrenToA(int count) throws Exception {
+        Long revisionId = null;
         for (int i = 1; i <= count; i++) {
             List<Instruction> instructions = new LinkedList<Instruction>();
             instructions.add(new AddNodeInstructionImpl("/a", "child" + i));
@@ -88,30 +84,17 @@ public class SimpleNodeScenario { // TOD
         return revisionId;
     }
 
-    /**
-     * Deletes the a node.
-     *
-     * <pre>
-     * &quot;-a&quot;
-     * </pre>
-     *
-     * @return The {@link RevisionId}.
-     * @throws Exception
-     *             If an error occurred.
-     */
-    public String delete_A() throws Exception {
+    public Long delete_A() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new RemoveNodeInstructionImpl("/", "a"));
 
         Commit commit = new CommitImpl("/", "-a", "This is a commit with deleted /a",
                 instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
-
-        return revisionId;
+        return command.execute();
     }
 
-    public String delete_B() throws Exception {
+    public Long delete_B() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new RemoveNodeInstructionImpl("/a", "b"));
         Commit commit = new CommitImpl("/a", "-b", "This is a commit with deleted /a/b",
@@ -120,18 +103,7 @@ public class SimpleNodeScenario { // TOD
         return command.execute();
     }
 
-    /**
-     * Updates the following nodes:
-     *
-     * <pre>
-     * TBD
-     * </pre>
-     *
-     * @return The {@link RevisionId}.
-     * @throws Exception
-     *             If an error occurred.
-     */
-    public String update_A_and_add_D_and_E() throws Exception {
+    public Long update_A_and_add_D_and_E() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/a", "d"));
         instructions.add(new AddNodeInstructionImpl("/a/b", "e"));
@@ -143,8 +115,6 @@ public class SimpleNodeScenario { // TOD
         Commit commit = new CommitImpl("", "TODO", "This is a commit with updated /a and added /a/d and /a/b/e",
                 instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
-        String revisionId = command.execute();
-
-        return revisionId;
+        return command.execute();
     }
 }



Mime
View raw message