use of org.apache.jackrabbit.test.NotExecutableException 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 org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class UpdateTest method testUpdateAddsMissingSubtree.
public void testUpdateAddsMissingSubtree() throws RepositoryException, NotExecutableException {
String srcWorkspace = getAnotherWorkspace();
// get the root node in the second workspace
Session session2 = getHelper().getSuperuserSession(srcWorkspace);
try {
// make sure the source-session has the corresponding node.
Node testRootW2 = (Node) session2.getItem(testRootNode.getCorrespondingNodePath(srcWorkspace));
// create test node in second workspace
Node aNode2 = testRootW2.addNode(nodeName1, testNodeType);
aNode2.addNode(nodeName2, testNodeType);
aNode2.setProperty(propertyName2, "test");
Property p2 = testRootW2.setProperty(propertyName1, "test");
testRootW2.save();
// call the update method on test node in default workspace
testRootNode.update(srcWorkspace);
// ok check if the child has been added
boolean allPresent = testRootNode.hasNode(nodeName1) && testRootNode.hasNode(nodeName1 + "/" + nodeName2) && testRootNode.hasProperty(nodeName1 + "/" + propertyName2) && testRootNode.hasProperty(propertyName1);
assertTrue("Node updated with Node.update() should have received childrens", allPresent);
} catch (PathNotFoundException e) {
throw new NotExecutableException();
} catch (ItemNotFoundException e) {
throw new NotExecutableException();
} finally {
session2.logout();
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class UpdateTest method testUpdateRemovesExtraProperty.
public void testUpdateRemovesExtraProperty() throws RepositoryException, NotExecutableException {
// create test node in default workspace
testRootNode.setProperty(propertyName2, "test");
testRootNode.save();
String srcWorkspace = getAnotherWorkspace();
// get the root node in the second workspace
Session session2 = getHelper().getSuperuserSession(srcWorkspace);
try {
// make sure the source-session has the corresponding node.
Node testRootW2 = (Node) session2.getItem(testRootNode.getCorrespondingNodePath(srcWorkspace));
if (testRootW2.hasProperty(propertyName2)) {
throw new NotExecutableException();
}
// call the update method on test node in default workspace
testRootNode.update(srcWorkspace);
// ok first check if node has no longer properties
assertFalse("Node updated with Node.update() should have property removed", testRootNode.hasProperty(propertyName2));
} catch (PathNotFoundException e) {
throw new NotExecutableException();
} catch (ItemNotFoundException e) {
throw new NotExecutableException();
} finally {
session2.logout();
}
}
use of org.apache.jackrabbit.test.NotExecutableException 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 org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class WorkspaceTest method testCreateWorkspace.
public void testCreateWorkspace() throws Exception {
Session s = null;
try {
Workspace wsp = superuser.getWorkspace();
String name = getNewWorkspaceName(wsp);
wsp.createWorkspace(name);
List<String> wsps = Arrays.asList(wsp.getAccessibleWorkspaceNames());
assertTrue(wsps.contains(name));
s = getHelper().getSuperuserSession(name);
Workspace newW = s.getWorkspace();
assertEquals(name, newW.getName());
} catch (UnsupportedRepositoryOperationException e) {
throw new NotExecutableException();
} catch (UnsupportedOperationException e) {
throw new NotExecutableException();
} finally {
if (s != null) {
s.logout();
}
}
}
Aggregations