You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ju...@apache.org on 2012/09/24 13:44:43 UTC
svn commit: r1389305 - in /jackrabbit/oak/trunk/oak-mongomk/src:
main/java/org/apache/jackrabbit/mongomk/command/
main/java/org/apache/jackrabbit/mongomk/impl/model/
test/java/org/apache/jackrabbit/mongomk/command/
test/java/org/apache/jackrabbit/mongo...
Author: jukka
Date: Mon Sep 24 11:44:42 2012
New Revision: 1389305
URL: http://svn.apache.org/viewvc?rev=1389305&view=rev
Log:
OAK-333: [MongoMK] Node not found when the path exceeds 1000 characters
Patch by Mete Atamel.
Modified:
jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongo.java
jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/CommitImpl.java
jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java
jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/ConcurrentCommitCommandMongoTest.java
jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongoTest.java
jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/scenario/SimpleNodeScenario.java
Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongo.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongo.java?rev=1389305&r1=1389304&r2=1389305&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongo.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/NodeExistsCommandMongo.java Mon Sep 24 11:44:42 2012
@@ -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 @@ import org.apache.jackrabbit.oak.commons
* @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
*/
public class NodeExistsCommandMongo extends AbstractCommand<Boolean> {
+
private final MongoConnection mongoConnection;
- private NodeMongo parentNode;
- private final String path;
- private String revisionId;
+ private final String revisionId;
+
+ private Node parentNode;
+ private String path;
/**
* Constructs a new {@code NodeExistsCommandMongo}.
@@ -54,21 +54,25 @@ public class NodeExistsCommandMongo exte
if (PathUtils.denotesRoot(path)) {
return true;
}
- ensureRevisionId();
- readParentNode();
- return childExists();
- }
- private void ensureRevisionId() throws Exception {
- if (revisionId == null) {
- revisionId = new GetHeadRevisionCommandMongo(mongoConnection).execute();
+ // Check that all the paths up to the parent are valid.
+ while (!PathUtils.denotesRoot(path)) {
+ readParentNode();
+ if (!childExists()) {
+ return false;
+ }
+ path = PathUtils.getParentPath(path);
}
+
+ return true;
}
private void readParentNode() throws Exception {
String parentPath = PathUtils.getParentPath(path);
- FetchNodeByPathQuery query = new FetchNodeByPathQuery(mongoConnection, parentPath, MongoUtil.toMongoRepresentation(revisionId));
- parentNode = query.execute();
+ // TODO - This used to be FetchNodeByPathQuery but changed to GetNodesCommandMongo to make
+ // sure nodes are in a valid commit etc. Check if GetNodesCommandMongo is really needed.
+ GetNodesCommandMongo command = new GetNodesCommandMongo(mongoConnection, parentPath, revisionId, -1);
+ parentNode = command.execute();
}
private boolean childExists() {
@@ -76,13 +80,13 @@ public class NodeExistsCommandMongo exte
return false;
}
- List<String> children = parentNode.getChildren();
+ Set<Node> children = parentNode.getChildren();
if (children == null || children.isEmpty()) {
return false;
}
- for (String child : children) {
- if (child.equals(PathUtils.getName(path))) {
+ for (Node child : children) {
+ if (child.getName().equals(PathUtils.getName(path))) {
return true;
}
}
Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/CommitImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/CommitImpl.java?rev=1389305&r1=1389304&r2=1389305&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/CommitImpl.java (original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/CommitImpl.java Mon Sep 24 11:44:42 2012
@@ -46,7 +46,7 @@ public class CommitImpl implements Commi
* @param diff The diff.
* @param message The message.
*/
- public CommitImpl(String path,String diff, String message) {
+ public CommitImpl(String path, String diff, String message) {
this(path, diff, message, new LinkedList<Instruction>());
}
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=1389305&r1=1389304&r2=1389305&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 Sep 24 11:44:42 2012
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.mongomk.imp
import org.apache.jackrabbit.mongomk.impl.model.CommitImpl;
import org.apache.jackrabbit.mongomk.impl.model.RemoveNodeInstructionImpl;
import org.apache.jackrabbit.mongomk.scenario.SimpleNodeScenario;
+import org.apache.jackrabbit.oak.commons.PathUtils;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -43,30 +44,30 @@ import org.junit.Test;
public class CommitCommandMongoTest extends BaseMongoTest {
@Test
- public void testAddIntermediataryNodes() throws Exception {
- // Assert.fail("Do it");
+ @Ignore // FIXME - Implement
+ public void addIntermediataryNodes() throws Exception {
}
@Test
- public void testAddNewNodesToSameParent() throws Exception {
+ public void addNewNodesToSameParent() throws Exception {
List<Instruction> instructions = new LinkedList<Instruction>();
instructions.add(new AddNodeInstructionImpl("/", "1"));
- Commit commit = new CommitImpl("This is the 1st commit", "/", "+1 : {}", instructions);
+ Commit commit = new CommitImpl("/", "+1 : {}", "This is the 1st commit", instructions);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
String firstRevisionId = command.execute();
instructions = new LinkedList<Instruction>();
instructions.add(new AddNodeInstructionImpl("/", "2"));
- commit = new CommitImpl("This is the 2nd commit", "/", "+2 : {}", instructions);
+ commit = new CommitImpl("/", "+2 : {}", "This is the 2nd commit", instructions);
command = new CommitCommandMongo(mongoConnection, commit);
String secondRevisionId = command.execute();
instructions = new LinkedList<Instruction>();
instructions.add(new AddNodeInstructionImpl("/", "3"));
- commit = new CommitImpl("This is the 3rd commit", "/", "+3 : {}", instructions);
+ commit = new CommitImpl("/", "+3 : {}", "This is the 3rd commit", instructions);
command = new CommitCommandMongo(mongoConnection, commit);
String thirdRevisionId = command.execute();
@@ -76,13 +77,14 @@ public class CommitCommandMongoTest exte
}
@Test
- public void testCommitAddNodes() throws Exception {
+ public void commitAddNodes() 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("This is a simple commit", "/", "+a : { b : {} , c : {} }", instructions);
+ Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
+ "This is a simple commit", instructions);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
String revisionId = command.execute();
@@ -97,7 +99,7 @@ public class CommitCommandMongoTest exte
}
@Test
- public void testCommitAddNodesAndPropertiesOutOfOrder() throws Exception {
+ public void commitAddNodesAndPropertiesOutOfOrder() throws Exception {
List<Instruction> instructions = new LinkedList<Instruction>();
instructions.add(new AddPropertyInstructionImpl("/a", "key1", "value1"));
instructions.add(new AddNodeInstructionImpl("/", "a"));
@@ -106,8 +108,9 @@ public class CommitCommandMongoTest exte
instructions.add(new AddPropertyInstructionImpl("/a/c", "key3", "value3"));
instructions.add(new AddNodeInstructionImpl("/a", "c"));
- Commit commit = new CommitImpl("This is a simple commit", "/",
- "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }", instructions);
+ 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();
@@ -126,7 +129,7 @@ public class CommitCommandMongoTest exte
}
@Test
- public void testCommitAddNodesWhichAlreadyExist() throws Exception {
+ public void commitAddNodesWhichAlreadyExist() throws Exception {
SimpleNodeScenario scenario1 = new SimpleNodeScenario(mongoConnection);
scenario1.create();
@@ -138,8 +141,9 @@ public class CommitCommandMongoTest exte
instructions.add(new AddNodeInstructionImpl("/a", "c"));
instructions.add(new AddPropertyInstructionImpl("/a/c", "key3", "value3"));
- Commit commit = new CommitImpl("This is a simple commit", "/",
- "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }", instructions);
+ 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();
@@ -158,7 +162,7 @@ public class CommitCommandMongoTest exte
}
@Test
- public void testCommitAndMergeNodes() throws Exception {
+ public void commitAndMergeNodes() throws Exception {
SimpleNodeScenario scenario1 = new SimpleNodeScenario(mongoConnection);
String firstRevisionId = scenario1.create();
String secondRevisionId = scenario1.update_A_and_add_D_and_E();
@@ -188,7 +192,7 @@ public class CommitCommandMongoTest exte
}
@Test
- public void testCommitContainsAllAffectedNodes() throws Exception {
+ public void commitContainsAllAffectedNodes() throws Exception {
SimpleNodeScenario scenario = new SimpleNodeScenario(mongoConnection);
String firstRevisionId = scenario.create();
String secondRevisionId = scenario.update_A_and_add_D_and_E();
@@ -198,13 +202,14 @@ public class CommitCommandMongoTest exte
}
@Test
- public void testRemoveNode() throws Exception {
+ 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("This is a simple commit", "/", "+a : { b : {} , c : {} }", instructions);
+ 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);
@@ -212,7 +217,7 @@ public class CommitCommandMongoTest exte
instructions = new LinkedList<Instruction>();
instructions.add(new RemoveNodeInstructionImpl("/", "a"));
- commit = new CommitImpl("This is a simple commit", "/", "-a", instructions);
+ commit = new CommitImpl("/", "-a", "This is a simple commit", instructions);
command = new CommitCommandMongo(mongoConnection, commit);
revisionId = command.execute();
Assert.assertNotNull(revisionId);
@@ -226,19 +231,19 @@ public class CommitCommandMongoTest exte
@Test
@Ignore // FIXME
- public void testRemoveNonExistentNode() throws Exception {
+ 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("Add nodes", "/", "+a : { b : {} }", instructions);
+ 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("Non-existent node delete", "/a", "-c", instructions);
+ commit = new CommitImpl("/a", "-c", "Non-existent node delete", instructions);
command = new CommitCommandMongo(mongoConnection, commit);
try {
command.execute();
@@ -249,13 +254,14 @@ public class CommitCommandMongoTest exte
}
@Test
- public void testExistingParentContainsChildren() throws Exception {
+ public void existingParentContainsChildren() throws Exception {
List<Instruction> instructions = new LinkedList<Instruction>();
instructions.add(new AddNodeInstructionImpl("/", "a"));
instructions.add(new AddNodeInstructionImpl("/", "b"));
instructions.add(new AddNodeInstructionImpl("/", "c"));
- Commit commit = new CommitImpl("This is a simple commit", "/", "+a : { b : {} , c : {} }", instructions);
+ Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
+ "This is a simple commit", instructions);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
String revisionId = command.execute();
@@ -269,15 +275,16 @@ public class CommitCommandMongoTest exte
}
@Test
- public void testMergePropertiesAndChildren_noneExistedAndNewAdded() throws Exception {
+ public void mergePropertiesAndChildren_noneExistedAndNewAdded() throws Exception {
List<Instruction> instructions = new LinkedList<Instruction>();
instructions.add(new AddNodeInstructionImpl("/", "a"));
instructions.add(new AddPropertyInstructionImpl("/a", "key1", "value1"));
instructions.add(new AddPropertyInstructionImpl("/a", "key2", "value2"));
instructions.add(new AddPropertyInstructionImpl("/a", "key3", "value3"));
- Commit commit = new CommitImpl("This is a simple commit", "/",
- "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }", instructions);
+ 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();
@@ -291,18 +298,16 @@ public class CommitCommandMongoTest exte
}
@Test
- public void testMergePropertiesAndChildren_someExistedAndNewAdded() throws Exception {
+ public void mergePropertiesAndChildren_someExistedAndNewAdded() throws Exception {
List<Instruction> instructions = new LinkedList<Instruction>();
instructions.add(new AddNodeInstructionImpl("/", "a"));
instructions.add(new AddPropertyInstructionImpl("/a", "existed_key1", "value1"));
instructions.add(new AddPropertyInstructionImpl("/a", "existed_key2", "value2"));
instructions.add(new AddPropertyInstructionImpl("/a", "existed_key3", "value3"));
- Commit commit = new CommitImpl(
- "This is a simple commit",
- "/",
+ Commit commit = new CommitImpl("/",
"+a : { \"existed_key1\" : \"value1\" , \"existed_key2\" : \"value2\" , \"existed_key3\" : \"value3\" }",
- instructions);
+ "This is a simple commit", instructions);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
String revisionId = command.execute();
@@ -312,8 +317,9 @@ public class CommitCommandMongoTest exte
instructions.add(new AddPropertyInstructionImpl("/a", "key2", "value2"));
instructions.add(new AddPropertyInstructionImpl("/a", "key3", "value3"));
- commit = new CommitImpl("This is a simple commit", "/",
- "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }", instructions);
+ commit = new CommitImpl("/",
+ "+a : { \"key1\" : \"value1\" , \"key2\" : \"value2\" , \"key3\" : \"value3\" }",
+ "This is a simple commit", instructions);
command = new CommitCommandMongo(mongoConnection, commit);
revisionId = command.execute();
@@ -327,13 +333,14 @@ public class CommitCommandMongoTest exte
}
@Test
- public void testNoOtherNodesTouched() throws Exception {
+ public void noOtherNodesTouched() throws Exception {
List<Instruction> instructions = new LinkedList<Instruction>();
instructions.add(new AddNodeInstructionImpl("/", "a"));
instructions.add(new AddNodeInstructionImpl("/", "b"));
instructions.add(new AddNodeInstructionImpl("/", "c"));
- Commit commit = new CommitImpl("This is a simple commit", "/", "+a : { b : {} , c : {} }", instructions);
+ Commit commit = new CommitImpl("/", "+a : { b : {} , c : {} }",
+ "This is a simple commit", instructions);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
String firstRevisionId = command.execute();
@@ -341,7 +348,7 @@ public class CommitCommandMongoTest exte
instructions.add(new AddNodeInstructionImpl("/a", "d"));
instructions.add(new AddNodeInstructionImpl("/a", "e"));
- commit = new CommitImpl("This is a simple commit", "/a", "+d: {} \n+e : {}", instructions);
+ commit = new CommitImpl("/a", "+d: {} \n+e : {}", "This is a simple commit", instructions);
command = new CommitCommandMongo(mongoConnection, commit);
String secondRevisionId = command.execute();
@@ -362,11 +369,11 @@ public class CommitCommandMongoTest exte
@Test
@Ignore /// FIXME
- public void testRootNodeHasEmptyRootPath() throws Exception {
+ public void rootNodeHasEmptyRootPath() throws Exception {
List<Instruction> instructions = new LinkedList<Instruction>();
instructions.add(new AddNodeInstructionImpl("", "/"));
- Commit commit = new CommitImpl("This is the root commit", "", "+/ : {}", instructions);
+ Commit commit = new CommitImpl("", "+/ : {}", "This is the root commit", instructions);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
String revisionId = command.execute();
@@ -374,4 +381,29 @@ public class CommitCommandMongoTest exte
MongoAssert.assertNodesExist("",
NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }", revisionId)));
}
+
+ @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;
+ }
+ }
}
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=1389305&r1=1389304&r2=1389305&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 Sep 24 11:44:42 2012
@@ -52,7 +52,8 @@ public class ConcurrentCommitCommandMong
for (int i = 0; i < numOfConcurrentThreads; ++i) {
List<Instruction> instructions = new LinkedList<Instruction>();
instructions.add(new AddNodeInstructionImpl("/", String.valueOf(i)));
- Commit commit = new CommitImpl("This is a concurrent commit", "/", "+" + i + " : {}", instructions);
+ Commit commit = new CommitImpl("/", "+" + i + " : {}",
+ "This is a concurrent commit", instructions);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit) {
@Override
protected boolean saveAndSetHeadRevision() throws Exception {
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=1389305&r1=1389304&r2=1389305&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 Sep 24 11:44:42 2012
@@ -30,7 +30,6 @@ import org.apache.jackrabbit.mongomk.imp
import org.apache.jackrabbit.mongomk.impl.model.CommitImpl;
import org.apache.jackrabbit.mongomk.impl.model.RemoveNodeInstructionImpl;
import org.apache.jackrabbit.mongomk.scenario.SimpleNodeScenario;
-import org.junit.Ignore;
import org.junit.Test;
@SuppressWarnings("javadoc")
@@ -119,7 +118,7 @@ public class NodeExistsCommandMongoTest
instructions.add(new AddNodeInstructionImpl("/a/b", "c"));
instructions.add(new AddNodeInstructionImpl("/a/b/c", "d"));
- Commit commit = new CommitImpl("Add nodes", "/", "TODO", instructions);
+ Commit commit = new CommitImpl("/", "TODO", "Add nodes", instructions);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection,
commit);
command.execute();
@@ -127,7 +126,7 @@ public class NodeExistsCommandMongoTest
// Remove b.
instructions = new LinkedList<Instruction>();
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 +138,34 @@ public class NodeExistsCommandMongoTest
}
@Test
+ public void existsInHeadRevision() throws Exception {
+
+ List<Instruction> instructions = new LinkedList<Instruction>();
+
+ // 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<Instruction>();
+ 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();
@@ -169,66 +196,4 @@ public class NodeExistsCommandMongoTest
exists = command.execute();
assertTrue(exists);
}
-
- @Test
- @Ignore
- public void testNodeNotFound() throws Exception {
-
- // adds nodes /a,/a/b,/a/b/c , checks if node a exists
- List<Instruction> instructions = new LinkedList<Instruction>();
-
- // 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<Instruction>();
- 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<Instruction>();
- 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<Instruction> instructions = new LinkedList<Instruction>();
-
- for (int i = 0; i < 1000; i++) {
- instructions.clear();
- instructions.add(new AddNodeInstructionImpl(path, "N" + i));
- Commit commit1 = new CommitImpl(path, "+N" + i + " : {}",
- "Add node N" + i, instructions);
- CommitCommandMongo command = new CommitCommandMongo(
- mongoConnection, commit1);
- command.execute();
- path = (path.endsWith("/")) ? (path = path + "N" + i)
- : (path = path + "/N" + i);
- //System.out.println("*********" + path.length() + "*****");
- }
-
- }
-
-}
+}
\ No newline at end of file
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=1389305&r1=1389304&r2=1389305&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 Sep 24 11:44:42 2012
@@ -67,8 +67,9 @@ public class SimpleNodeScenario { // TOD
instructions.add(new AddPropertyInstructionImpl("/a/b", "string", "foo"));
instructions.add(new AddPropertyInstructionImpl("/a/c", "bool", true));
- Commit commit = new CommitImpl("This is the simple node scenario with nodes /, /a, /a/b, /a/c", "/",
- "+a : { \"int\" : 1 , \"b\" : { \"string\" : \"foo\" } , \"c\" : { \"bool\" : true } } }", instructions);
+ Commit commit = new CommitImpl("/",
+ "+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();
@@ -80,7 +81,7 @@ public class SimpleNodeScenario { // TOD
for (int i = 1; i <= count; i++) {
List<Instruction> instructions = new LinkedList<Instruction>();
instructions.add(new AddNodeInstructionImpl("/a", "child" + i));
- Commit commit = new CommitImpl("Add child" + i, "/a", "TODO", instructions);
+ Commit commit = new CommitImpl("/a", "TODO", "Add child" + i, instructions);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
revisionId = command.execute();
}
@@ -102,7 +103,8 @@ public class SimpleNodeScenario { // TOD
List<Instruction> instructions = new LinkedList<Instruction>();
instructions.add(new RemoveNodeInstructionImpl("/", "a"));
- Commit commit = new CommitImpl("This is a commit with deleted /a", "/", "-a", instructions);
+ Commit commit = new CommitImpl("/", "-a", "This is a commit with deleted /a",
+ instructions);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
String revisionId = command.execute();
@@ -112,7 +114,8 @@ public class SimpleNodeScenario { // TOD
public String delete_B() throws Exception {
List<Instruction> instructions = new LinkedList<Instruction>();
instructions.add(new RemoveNodeInstructionImpl("/a", "b"));
- Commit commit = new CommitImpl("This is a commit with deleted /a/b", "/a", "-b", instructions);
+ Commit commit = new CommitImpl("/a", "-b", "This is a commit with deleted /a/b",
+ instructions);
CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
return command.execute();
}
@@ -137,7 +140,7 @@ public class SimpleNodeScenario { // TOD
instructions.add(new AddPropertyInstructionImpl("/a/b/e", "array", new Object[] { 123, null, 123.456D,
"for:bar", Boolean.TRUE }));
- Commit commit = new CommitImpl("This is a commit with updated /a and added /a/d and /a/b/e", "", "TODO",
+ 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();