use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class UUIDLookupTest method beforeSuite.
@Override
public void beforeSuite() throws RepositoryException {
session = getRepository().login(getCredentials());
try {
ensurePropertyIndexes();
} catch (InvalidItemStateException e) {
// some other oak instance probably created the same
// index definition concurrently. refresh and try again
// do not catch exception if it fails again.
session.refresh(false);
ensurePropertyIndexes();
}
root = session.getRootNode().addNode("testroot" + TEST_ID, "nt:unstructured");
for (int i = 0; i < NODE_COUNT; i++) {
Node node = root.addNode("node" + i, "nt:unstructured");
node.setProperty("jcr:uuid", createUUID(i));
session.save();
}
String lookupMode = lookupByQuery ? "query" : "Session#getNodeByIdentifier";
System.out.printf("No of indexes (%s) %d, Lookup by (%s)[%s] %n", noOfIndex, noOfIndex, "lookupByQuery", lookupMode);
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class RemoveNodeTest method testInvalidStateRemovedNode3.
public void testInvalidStateRemovedNode3() throws RepositoryException {
Node childNode = testRootNode.addNode(nodeName1, testNodeType);
superuser.save();
// get the node with session 2
Session otherSession = getHelper().getReadWriteSession();
try {
Node childNode2 = (Node) otherSession.getItem(childNode.getPath());
childNode.remove();
superuser.save();
// try to remove already removed node with session 2
try {
childNode2.refresh(false);
childNode2.remove();
otherSession.save();
fail("Removing a node already removed by other session should throw an InvalidItemStateException!");
} catch (InvalidItemStateException e) {
//ok, works as expected
}
} finally {
otherSession.logout();
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class MoveMultipleTest method testRevertingMoveParentAndNewChild.
/**
* Separately move the persisted 'moveNode' and its 'new' child node.
* Check if reverting the changes removes the 'new' child and moves
* the persisted moveNode back.
*/
public void testRevertingMoveParentAndNewChild() throws RepositoryException {
Node moveNode2 = moveNode.addNode(nodeName3, testNodeType);
doMove(moveNode.getPath(), destinationPath);
doMove(moveNode2.getPath(), srcParentNode.getPath() + "/" + moveNode2.getName());
doMove(moveNode.getPath(), originalPath);
testRootNode.refresh(false);
// moveNode2 which has never been saved, must be removed
try {
moveNode2.getParent();
fail("Reverting the move of a 'new' node must remove the new node as well.");
} catch (InvalidItemStateException e) {
// ok
}
// the persistent 'moveNode' must be moved back to its original position.
assertTrue(moveNode.getParent().isSame(srcParentNode));
assertFalse(destParentNode.hasNodes());
}
use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class ConflictResolutionTest method deleteChangedNodeOps.
private void deleteChangedNodeOps(String node) throws RepositoryException {
getAdminSession().getRootNode().addNode(node).addNode("jcr:content").addNode("metadata");
getAdminSession().save();
Session session1 = createAdminSession();
Session session2 = createAdminSession();
try {
session1.getNode("/" + node + "/jcr:content").remove();
session2.getNode("/" + node + "/jcr:content/metadata").setProperty("updated", "myself");
session2.save();
try {
session1.save();
fail("Expected InvalidItemStateException");
} catch (InvalidItemStateException expected) {
assertThat("Expecting 'Unresolved conflicts in /" + node + "'", expected.getMessage(), containsString("OakState0001: Unresolved conflicts in /" + node + ""));
}
} finally {
session1.logout();
session2.logout();
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class MoveRemoveTest method removeExistingNodeRefresh.
@Test
public void removeExistingNodeRefresh() throws RepositoryException {
Session session = getAdminSession();
session.getRootNode().addNode("new");
session.save();
Session session2 = createAdminSession();
Node n2 = session2.getNode("/new");
Node n = session.getNode("/new");
n.remove();
session.save();
session2.refresh(false);
try {
n2.getPath();
fail();
} catch (InvalidItemStateException e) {
}
session.getRootNode().addNode("new");
session.save();
session2.refresh(false);
assertEquals("/new", n2.getPath());
session2.logout();
}
Aggregations