use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class MoveToNewTest method testMoveTwice.
public void testMoveTwice() throws RepositoryException {
Session s = testRootNode.getSession();
String srcPath = moveNode.getPath();
s.move(srcPath, destinationPath);
srcParentNode.remove();
// create new parent
Node newParent = testRootNode.addNode(nodeName1);
s.move(destinationPath, srcPath);
assertTrue(newParent.isNew());
assertTrue(newParent.hasNode(nodeName2));
assertTrue(destParentNode.isNew());
assertFalse(destParentNode.hasNode(nodeName2));
// remove the tmp destination parent node.
destParentNode.remove();
assertTrue(newParent.isNew());
assertTrue(newParent.hasNode(nodeName2));
assertTrue(moveNode.isModified());
testRootNode.save();
assertFalse(s.itemExists(Text.getRelativeParent(destinationPath, 1)));
assertTrue(s.itemExists(srcPath));
assertFalse(moveNode.isModified() || newParent.isNew() || srcParentNode.isModified());
try {
srcParentNode.getNode(nodeName2);
fail("src parent must be removed");
} catch (InvalidItemStateException e) {
// ok.
}
assertTrue(moveNode.isSame(newParent.getNode(nodeName2)));
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class IsSameTest method testShadowingItems3.
public void testShadowingItems3() throws RepositoryException {
Node n = testRootNode.addNode(nodeName1, testNodeType);
Property p = n.setProperty(propertyName1, "anyValue");
testRootNode.save();
p.remove();
Property p2 = n.setProperty(propertyName1, "anyValue");
try {
assertFalse(p2.isSame(p));
} catch (InvalidItemStateException e) {
// ok as well.
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class RefreshTrueTest method testRemovedProperty.
public void testRemovedProperty() throws RepositoryException {
Property p = testRootNode.setProperty(propertyName1, testValue);
testRootNode.save();
p.remove();
testRootNode.refresh(true);
// Property p must remain removed
try {
p.getString();
fail("Refresh 'true' must not revert removal of an item.");
} catch (InvalidItemStateException e) {
//ok
}
assertFalse("Refresh 'true' must not revert removal of an item.", testRootNode.hasProperty(propertyName1));
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class RefreshFalseTest method testShadowingProperty.
public void testShadowingProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
Property p = testRootNode.setProperty(propertyName1, testValue);
testRootNode.save();
p.remove();
Property pNew = testRootNode.setProperty(propertyName1, "SomeOtherTestValue");
testRootNode.refresh(false);
try {
pNew.getString();
fail("Refresh 'false' must remove a new (shadowing) property and bring 'removed' persistent property back to life.");
} catch (InvalidItemStateException e) {
// ok
}
// Property p must be reverted to 'existing' -> getString must succeed.
p.getString();
// similarly accessing the property again must succeed.
Property pAgain = testRootNode.getProperty(propertyName1);
assertTrue("Refresh 'false' must remove a new property and bring 'removed' persistent property back to life.", p.isSame(pAgain));
}
use of javax.jcr.InvalidItemStateException in project jackrabbit by apache.
the class RefreshFalseTest method testNewProperty.
public void testNewProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
Property p = testRootNode.setProperty(propertyName1, testValue);
testRootNode.refresh(false);
try {
p.getString();
fail("Refresh 'false' must invalidate a new child property");
} catch (InvalidItemStateException e) {
// ok
}
assertFalse("Refresh 'false' must remove a new child property", testRootNode.hasProperty(propertyName1));
}
Aggregations