use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class WorkspaceCopyVersionableTest method testCopyNodesVersionableAndCheckedIn.
/**
* A VersionException is thrown if the parent node of destAbsPath is
* versionable and checked-in, or is non-versionable but its nearest
* versionable ancestor is checked-in.
*/
public void testCopyNodesVersionableAndCheckedIn() throws RepositoryException, NotExecutableException {
// prepare the test data
// create a non-versionable node below a versionable node
// required for having a nearest versionable ancestor to a nonversionable sub node
String dstAbsPath = node1.getPath() + "/" + node2.getName();
workspace.copy(node2.getPath(), dstAbsPath);
try {
// make parent node versionable and check-in
addMixinVersionableToNode(testRootNode, node1);
node1.checkin();
} catch (ConstraintViolationException ex) {
throw new NotExecutableException("server does not support making the parent versionable: " + ex.getMessage());
}
// 1. parent node of destAbsPath is non-versionable but its nearest versionable ancestor is checked-in
try {
workspace.copy(node2.getPath(), dstAbsPath + "/" + node2.getName());
fail("Copying a node to a node's versionable and checked-in nearest ancestor node of destAbsPath should throw VersionException.");
} catch (VersionException e) {
// successful
}
// 2. parent node of destAbsPath is versionable and checked-in
try {
workspace.copy(node2.getPath(), node1.getPath() + "/" + node2.getName());
fail("Copying a node to a versionable and checked-in parent node of destAbsPath should throw VersionException.");
} catch (VersionException e) {
// successful
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class MergeNodeTest method disable_testMergeLocked.
/**
* Tests if a {@link LockException} is thrown when merge is called on a
* locked node.
* @throws NotExecutableException if repository does not support locking.
*/
@SuppressWarnings("deprecation")
public void disable_testMergeLocked() throws NotExecutableException, RepositoryException {
if (!isSupported(Repository.OPTION_LOCKING_SUPPORTED)) {
throw new NotExecutableException("Locking is not supported.");
}
// try to make nodeToMerge lockable if it is not
ensureMixinType(nodeToMerge, mixLockable);
nodeToMerge.getParent().save();
// lock the node
// remove first slash of path to get rel path to root
String pathRelToRoot = nodeToMerge.getPath().substring(1);
// access node through another session to lock it
Session session2 = getHelper().getSuperuserSession();
try {
Node node2 = session2.getRootNode().getNode(pathRelToRoot);
node2.lock(false, false);
try {
nodeToMerge.merge(workspace.getName(), false);
fail("merge must throw a LockException if applied on a " + "locked node");
} catch (LockException e) {
// success
}
node2.unlock();
} finally {
session2.logout();
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class MoveTest method testMovedNodeIsSame.
/**
* Test if the accessing the moved node from the session returns the same
* Node object, than the Node which was moved before.
*
* @throws RepositoryException
* @throws NotExecutableException
*/
public void testMovedNodeIsSame() throws RepositoryException, NotExecutableException {
if (destParentNode.hasNode(nodeName2)) {
throw new NotExecutableException(destParentNode + " already has child node " + ". Test cannot be preformed if SNS is present.");
}
String oldPath = moveNode.getPath();
String newPath = destParentNode.getPath() + "/" + nodeName2;
//move the node
doMove(oldPath, destinationPath);
Item movedItem = superuser.getItem(newPath);
assertTrue("Moved Node must be the same after the move.", movedItem.isSame(moveNode));
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class MoveTest method testMoveFile.
public void testMoveFile() throws RepositoryException, NotExecutableException {
// create a new file
String parentPath;
String filePath;
try {
Node parent = testRootNode.addNode("parent");
Node n = JcrUtils.putFile(parent, "file", "text/plain", new ByteArrayInputStream("data".getBytes()));
parentPath = parent.getPath();
filePath = n.getPath();
superuser.save();
} catch (RepositoryException e) {
throw new NotExecutableException();
}
Session s = getHelper().getSuperuserSession();
try {
Node n1 = s.getNode(filePath);
Node n2 = n1.getNode("jcr:content");
n2.setProperty("jcr:data", new java.io.ByteArrayInputStream("data2".getBytes()));
n2.save();
String destPath = parentPath + "1";
if (isSessionMove()) {
s.move(parentPath, destPath);
s.save();
} else {
s.getWorkspace().move(parentPath, destPath);
}
Node n3 = s.getNode(destPath + "/file");
Node n4 = n3.getNode("jcr:content");
n4.refresh(false);
// call must succeed (see JCR-2472)
Node n5 = n3.getNode("jcr:content");
} finally {
s.logout();
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class MultiValuedPropertyTest method testGetStreamFromMultivalued.
/**
* Tests if Property.getStream() fails with ValueFormatException for
* multivalued properties.
*
* @throws RepositoryException
* @throws NotExecutableException
*/
public void testGetStreamFromMultivalued() throws RepositoryException, NotExecutableException {
Property prop = PropertyUtil.searchMultivalProp(testRootNode);
if (prop == null) {
throw new NotExecutableException("No multivalued property found.");
} else {
try {
prop.getStream();
fail("Property.getStream() must fail with ValueFormatException for any multivalued property.");
} catch (ValueFormatException vfe) {
// ok
}
}
}
Aggregations