Index: oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongo.java =================================================================== --- oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongo.java (revision 1388461) +++ oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongo.java (working copy) @@ -16,13 +16,11 @@ */ package org.apache.jackrabbit.mongomk.command; -import java.util.List; +import java.util.Set; import org.apache.jackrabbit.mongomk.MongoConnection; import org.apache.jackrabbit.mongomk.api.command.AbstractCommand; -import org.apache.jackrabbit.mongomk.model.NodeMongo; -import org.apache.jackrabbit.mongomk.query.FetchNodeByPathQuery; -import org.apache.jackrabbit.mongomk.util.MongoUtil; +import org.apache.jackrabbit.mongomk.api.model.Node; import org.apache.jackrabbit.oak.commons.PathUtils; /** @@ -31,10 +29,12 @@ * @author (); instructions.add(new RemoveNodeInstructionImpl("/a", "b")); - commit = new CommitImpl("Delete /b", "/a", "-b", instructions); + commit = new CommitImpl("/a", "-b", "Delete /b", instructions); command = new CommitCommandMongo(mongoConnection, commit); command.execute(); @@ -139,6 +139,34 @@ } @Test + public void existsInHeadRevision() throws Exception { + + List instructions = new LinkedList(); + + // Add /a + instructions.add(new AddNodeInstructionImpl("/", "a")); + Commit commit1 = new CommitImpl("/", "+a : {}", "Add node a", + instructions); + CommitCommandMongo command = new CommitCommandMongo(mongoConnection, + commit1); + command.execute(); + + // Add /a/b + instructions = new LinkedList(); + instructions.add(new AddNodeInstructionImpl("/a", "b")); + Commit commit2 = new CommitImpl("/a", "+b : {}", "Add node a/b", + instructions); + command = new CommitCommandMongo(mongoConnection, commit2); + command.execute(); + + // Verify /a is visible in the head revision + NodeExistsCommandMongo command2 = new NodeExistsCommandMongo( + mongoConnection, "/a", null); + boolean exists = command2.execute(); + assertTrue("The node a is not found in the head revision!", exists); + } + + @Test public void existsInOldRevNotInNewRev() throws Exception { SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection); String rev1 = scenario.create(); @@ -172,47 +200,7 @@ @Test @Ignore - public void testNodeNotFound() throws Exception { - - // adds nodes /a,/a/b,/a/b/c , checks if node a exists - List instructions = new LinkedList(); - - // commit node /a - instructions.add(new AddNodeInstructionImpl("/", "a")); - Commit commit1 = new CommitImpl("/", "+a : {}", "Add node a", - instructions); - CommitCommandMongo command = new CommitCommandMongo(mongoConnection, - commit1); - command.execute(); - - // commit node /a/b - instructions = new LinkedList(); - instructions.add(new AddNodeInstructionImpl("/a", "b")); - Commit commit2 = new CommitImpl("/a", "+b : {}", "Add node a/b", - instructions); - command = new CommitCommandMongo(mongoConnection, commit2); - command.execute(); - - // commit node /a/b/c - instructions = new LinkedList(); - instructions.add(new AddNodeInstructionImpl("/a/b", "c")); - Commit commit3 = new CommitImpl("a/b", "+c : {}", "Add node a/b/c", - instructions); - command = new CommitCommandMongo(mongoConnection, commit3); - command.execute(); - - // verify if node a is visible in the head revision - NodeExistsCommandMongo isNodeVisible = new NodeExistsCommandMongo( - mongoConnection, "/a", null); - boolean exists = isNodeVisible.execute(); - assertTrue("The node a is not found in the head revision!", exists); - - } - - @Test - @Ignore public void testTreeDepth() throws Exception { - String path = "/"; List instructions = new LinkedList(); @@ -226,7 +214,6 @@ command.execute(); path = (path.endsWith("/")) ? (path = path + "N" + i) : (path = path + "/N" + i); - //System.out.println("*********" + path.length() + "*****"); } }