use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class NodeSetPrimaryTypeTest method testCheckedIn.
/**
* Tests if <code>Node.setPrimaryType(String)</code> throws a
* <code>VersionException</code> if <code>Node</code> is checked-in.
*/
public void testCheckedIn() throws NotExecutableException, RepositoryException {
Session session = testRootNode.getSession();
if (!isSupported(Repository.OPTION_VERSIONING_SUPPORTED)) {
throw new NotExecutableException("Versioning is not supported.");
}
// create a node that is versionable
Node node = testRootNode.addNode(nodeName1, testNodeType);
// or try to make it versionable if it is not
ensureMixinType(node, mixVersionable);
superuser.save();
String primaryTypeName = getPrimaryTypeName(session, node);
if (primaryTypeName == null) {
throw new NotExecutableException("No testable node type found");
}
node.checkin();
try {
node.setPrimaryType(primaryTypeName);
fail("Node.setPrimaryType(String) must throw a VersionException if the node is checked-in.");
} catch (VersionException e) {
// success
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class NodeSetPrimaryTypeTest method testLocked.
/**
* Tests if <code>Node.setPrimaryType(String)</code> throws a
* <code>LockException</code> if <code>Node</code> is locked.
*/
public void testLocked() throws NotExecutableException, RepositoryException {
Session session = testRootNode.getSession();
if (!isSupported(Repository.OPTION_LOCKING_SUPPORTED)) {
throw new NotExecutableException("Locking is not supported.");
}
// create a node that is lockable
Node node = testRootNode.addNode(nodeName1, testNodeType);
// or try to make it lockable if it is not
ensureMixinType(node, mixLockable);
testRootNode.getSession().save();
String primaryTypeName = getPrimaryTypeName(session, node);
if (primaryTypeName == null) {
throw new NotExecutableException("No testable node type found");
}
// remove first slash of path to get rel path to root
String pathRelToRoot = node.getPath().substring(1);
// access node through another session to lock it
Session session2 = getHelper().getSuperuserSession();
try {
Node node2 = session2.getRootNode().getNode(pathRelToRoot);
node2.lock(true, true);
try {
// implementation specific: either throw LockException upon
// addMixin or upon save.
node.setPrimaryType(primaryTypeName);
node.save();
fail("Node.setPrimaryType(String) must throw a LockException if the node is locked.");
} catch (LockException e) {
// success
}
// unlock to remove node at tearDown()
node2.unlock();
} finally {
session2.logout();
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class NodeReadMethodsTest method testGetPrimaryItemItemNotFoundException.
/**
* Test if getPrimaryItem does throw an ItemNotFoundException if the primary
* node type does not define a primary item. Therefor a node without a
* primary item is located recursively in the entire repository. A
* NotExecutableException is thrown when no such node is found.
*/
public void testGetPrimaryItemItemNotFoundException() throws NotExecutableException, RepositoryException {
Node node = locateNodeWithoutPrimaryItem(testRootNode);
if (node == null) {
throw new NotExecutableException("Workspace does not contain a node without primary item defined");
}
try {
node.getPrimaryItem();
fail("getPrimaryItem() must throw a ItemNotFoundException " + "if the primary node type does not define one");
} catch (ItemNotFoundException e) {
// success
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class NodeReadMethodsTest method testGetUUIDOfNonReferenceableNode.
/**
* Test if getUUID() throws a UnsupportedRepositoryOperationException if
* Node is not referenceable
*/
public void testGetUUIDOfNonReferenceableNode() throws NotExecutableException, RepositoryException {
// find a node NOT of type mix:referenceable
Node node = locateNonReferenceableNode(testRootNode);
if (node == null) {
throw new NotExecutableException("Workspace does not contain a non referenceable node");
}
try {
node.getUUID();
fail("UnsupportedRepositoryOperationException expected");
} catch (UnsupportedRepositoryOperationException e) {
// success
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class NodeReadMethodsTest method testHasNode.
/**
* Test if hasNode(String relPath) returns true if the required node exists
* and false if it doesn't. Tested node: root
*/
public void testHasNode() throws NotExecutableException, RepositoryException {
Node node = testRootNode;
NodeIterator nodes = node.getNodes();
StringBuffer notExistingNodeName = new StringBuffer();
while (nodes.hasNext()) {
Node n = nodes.nextNode();
assertTrue("hasNode(String relPath) returns false although " + "node at relPath is existing", node.hasNode(n.getName()));
notExistingNodeName.append(n.getName() + "X");
}
if (notExistingNodeName.toString().equals("")) {
throw new NotExecutableException("Workspace does not have sufficient content for this test. " + "Root node must have at least one child node.");
}
assertFalse("hasNode(String relPath) returns true although " + "node at relPath is not existing", node.hasNode(notExistingNodeName.toString().replaceAll(":", "")));
}
Aggregations