use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class ExternalModificationTest method testStaleDestroyed.
public void testStaleDestroyed() throws RepositoryException, NotExecutableException {
Node refNode2 = (Node) testSession.getItem(refNode.getPath());
refNode2.addMixin(mixLockable);
superuser.move(refNode.getPath(), destParentNode.getPath() + "/" + nodeName2);
superuser.save();
testSession.getItem(destParentNode.getPath() + "/" + nodeName2);
assertItemStatus(refNode2, Status.STALE_DESTROYED);
try {
refNode2.refresh(false);
fail();
} catch (InvalidItemStateException e) {
// correct behaviour
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class ExternalModificationTest method testExternalRemoval2.
public void testExternalRemoval2() throws RepositoryException, NotExecutableException {
Node childN = refNode.addNode(nodeName3);
Property p = childN.setProperty(propertyName1, "anyvalue");
refNode.save();
String uuid = refNode.getUUID();
Node refNode2 = testSession.getNodeByUUID(uuid);
Node c2 = (Node) testSession.getItem(childN.getPath());
Property p2 = (Property) testSession.getItem(p.getPath());
// transiently remove the property -> test effect of external removal.
p2.remove();
String srcPath = refNode.getPath();
String destPath = destParentNode.getPath() + "/" + nodeName2;
superuser.move(srcPath, destPath);
superuser.save();
try {
refNode2.refresh(true);
Node parent = refNode2.getParent();
} catch (InvalidItemStateException e) {
}
assertItemStatus(refNode2, Status.REMOVED);
assertItemStatus(c2, Status.STALE_DESTROYED);
assertItemStatus(p2, Status.REMOVED);
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class ExternalModificationTest method testConflictingAddMixin.
public void testConflictingAddMixin() throws RepositoryException, NotExecutableException {
Node refNode2 = (Node) testSession.getItem(refNode.getPath());
refNode2.addMixin(mixLockable);
superuser.move(refNode.getPath(), destParentNode.getPath() + "/" + nodeName2);
superuser.save();
try {
refNode2.refresh(true);
Node parent = refNode2.getParent();
if (parent.isSame(testSession.getItem(destParentNode.getPath()))) {
// node has been automatically moved to new place
assertItemStatus(refNode2, Status.EXISTING_MODIFIED);
} else if (!isItemStatus(refNode2, Status.EXISTING_MODIFIED)) {
// external removal was detected either by observation or be
// batch-reading the parent -> status must be stale.
assertItemStatus(refNode2, Status.STALE_DESTROYED);
}
} catch (InvalidItemStateException e) {
// no automatic move of the externally moved node. ok.
log.debug(e.getMessage());
// since refNode2 has pending modifications its status should be
// changed to STALE_DESTROYED.
assertItemStatus(refNode2, Status.STALE_DESTROYED);
Node refAgain = testSession.getNodeByUUID(refNode.getUUID());
assertTrue(refAgain.getParent().isSame(testSession.getItem(destParentNode.getPath())));
assertFalse(refAgain.isNodeType(mixLockable));
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class ExternalModificationTest method testRefreshMovedReferenceableNode.
public void testRefreshMovedReferenceableNode() throws RepositoryException, NotExecutableException {
Node refNode2 = (Node) testSession.getItem(refNode.getPath());
superuser.move(refNode.getPath(), destParentNode.getPath() + "/" + nodeName2);
superuser.save();
try {
refNode2.refresh(true);
Node parent = refNode2.getParent();
if (parent.isSame(testSession.getItem(destParentNode.getPath()))) {
// node has been automatically moved to new place
assertItemStatus(refNode2, Status.EXISTING);
} else {
assertItemStatus(refNode2, Status.REMOVED);
}
} catch (InvalidItemStateException e) {
// no automatic move of the externally moved node. ok.
log.debug(e.getMessage());
// since node had no pending changes -> status should be changed
// to REMOVED.
assertItemStatus(refNode2, Status.REMOVED);
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class GetPropertyTest method testGetPropertyOfRemovedAncestor.
public void testGetPropertyOfRemovedAncestor() throws RepositoryException {
Session rw = getHelper().getReadWriteSession();
try {
// add modification to a property.
Property p = (Property) rw.getItem(prop1Path);
p.setValue("changedValue");
// transiently remove the test root node
rw.getItem(testRootNode.getPath()).remove();
try {
p.getValue();
fail("modified property must be marked removed upon parent removal");
} catch (InvalidItemStateException e) {
// success
}
try {
rw.getItem(prop1Path);
fail("modified property must be marked removed upon parent removal");
} catch (PathNotFoundException e) {
// success
}
try {
Property p2 = (Property) rw.getItem(prop2Path);
fail("existing property must be marked removed upon parent removal");
} catch (PathNotFoundException e) {
// success
}
// revert all transient modifications
rw.refresh(false);
Property pAgain = (Property) rw.getItem(prop1Path);
// TODO: for generic jsr 170 test: change assert to p.isSame(pAgain)
assertTrue(p.isSame(pAgain));
assertEquals("string1", p.getString());
} finally {
rw.logout();
}
}
Aggregations