use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class RestoreTest method testRestoreChild1Jcr2_2.
public void testRestoreChild1Jcr2_2() throws RepositoryException {
versionableNode.addNode("child1");
versionableNode.getSession().save();
Version v1 = versionManager.checkin(versionableNode.getPath());
versionManager.checkout(versionableNode.getPath());
Version v2 = versionManager.checkin(versionableNode.getPath());
versionManager.restore(v1, true);
assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
versionManager.restore(version, true);
assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
try {
versionManager.restore(v2, true);
} catch (RepositoryException e) {
fail("Node.restore('1.3') must fail.");
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class RestoreTest method testRestoreChild1Jcr2_3.
public void testRestoreChild1Jcr2_3() throws RepositoryException {
versionableNode.addNode("child1");
versionableNode.getSession().save();
Version v1 = versionManager.checkin(versionableNode.getPath());
versionManager.checkout(versionableNode.getPath());
Version v2 = versionManager.checkin(versionableNode.getPath());
versionManager.restore(versionableNode.getPath(), v1.getName(), true);
assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
versionManager.restore(versionableNode.getPath(), version.getName(), true);
assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
try {
versionManager.restore(versionableNode.getPath(), v2.getName(), true);
} catch (RepositoryException e) {
fail("Node.restore('1.3') must fail.");
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class UpdateTest method testPendingChangesOnOtherNode.
public void testPendingChangesOnOtherNode() throws RepositoryException, NotExecutableException {
try {
Node root = testRootNode.getSession().getRootNode();
if (root.isSame(testRootNode)) {
throw new NotExecutableException();
}
if (root.canAddMixin(mixLockable)) {
root.addMixin(mixLockable);
} else {
root.setProperty(propertyName1, "anyValue");
}
} catch (RepositoryException e) {
throw new NotExecutableException();
}
String srcWorkspace = getAnotherWorkspace();
try {
testRootNode.update(srcWorkspace);
fail("Update while changes are pending must fail with InvalidItemStateException");
} catch (InvalidItemStateException e) {
// ok
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class WorkspaceMoveTest method testMovePropertyExists.
/**
* Tries to move a node using to a location where a property already exists
* with same name.
* <br/> <br/>
* With JCR 1.0 this should throw an <code>{@link javax.jcr.ItemExistsException}</code>.
* With JCR 2.0 the support for same-named property and node is optional and
* the expected behaviour depends on the
* {@link Repository#OPTION_NODE_AND_PROPERTY_WITH_SAME_NAME_SUPPORTED} descriptor.
*/
@Override
public void testMovePropertyExists() throws RepositoryException, NotExecutableException {
// try to create a property with the name of the node to be moved
// to the destination parent
Property destProperty;
try {
destProperty = destParentNode.setProperty(nodeName2, "anyString");
destParentNode.save();
} catch (RepositoryException e) {
throw new NotExecutableException("Cannot create property with name '" + nodeName2 + "' and value 'anyString' at move destination.");
}
// TODO: fix 2.0 behaviour according to the OPTION_NODE_AND_PROPERTY_WITH_SAME_NAME_SUPPORTED descriptor
if ("1.0".equals(getHelper().getRepository().getDescriptor(Repository.SPEC_VERSION_DESC))) {
try {
// move the node
doMove(moveNode.getPath(), destProperty.getPath());
fail("Moving a node to a location where a property exists must throw ItemExistsException");
} catch (ItemExistsException e) {
// ok, works as expected
}
} else {
// JCR 2.0 move the node: same name property and node must be supported
doMove(moveNode.getPath(), destProperty.getPath());
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class AddMixinTest method testImplicitMixinOnNewNode.
/**
* Implementation specific test adding a new Node with a nodeType, that has
* a mixin-supertype. The mixin must only take effect upon save.
*
* @throws NotExecutableException
* @throws RepositoryException
*/
public void testImplicitMixinOnNewNode() throws NotExecutableException, RepositoryException {
Node newNode;
try {
String ntResource = superuser.getNamespacePrefix(NS_NT_URI) + ":resource";
newNode = testRootNode.addNode(nodeName1, ntResource);
} catch (RepositoryException e) {
throw new NotExecutableException();
}
assertFalse("Implict Mixin inherited by primary Nodetype must not be active before Node has been saved.", newNode.isNodeType(mixReferenceable));
NodeType[] mixins = newNode.getMixinNodeTypes();
for (int i = 0; i < mixins.length; i++) {
if (mixins[i].getName().equals(testNodeType)) {
fail("Implict Mixin inherited by primary Nodetype must not be active before Node has been saved.");
}
}
}
Aggregations