use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class NodeDiscoveringNodeTypesTest method testGetMixinNodeTypes.
/**
* Test if getMixinNodeType returns the node types according to the property
* "jcr:mixinTypes". Therefore a node with mixin types is located recursively
* in the entire repository. A NotExecutableException is thrown when no such
* node is found.
*/
public void testGetMixinNodeTypes() throws NotExecutableException, RepositoryException {
if (childNode == null) {
throw new NotExecutableException("Workspace does not have sufficient content for this test. " + "Root node must have at least one child node.");
}
Node node = locateNodeWithMixinNodeTypes(testRootNode);
if (node == null) {
throw new NotExecutableException("Workspace does not contain a node with mixin node types defined");
}
Value[] names = node.getProperty(jcrMixinTypes).getValues();
NodeType[] types = node.getMixinNodeTypes();
assertEquals("getMixinNodeTypes() does not return the same number of " + "node types as " + "getProperty(\"jcr:mixinTypes\").getValues()", types.length, names.length);
StringBuffer namesString = new StringBuffer();
for (int i = 0; i < names.length; i++) {
namesString.append("|" + names[i].getString() + "|");
}
for (int i = 0; i < types.length; i++) {
String pattern = "|" + types[i].getName() + "|";
assertTrue("getMixinNodeTypes() does not return the same node" + "types as getProperty(\"jcr:mixinTypes\").getValues()", namesString.indexOf(pattern) != -1);
assertTrue("All nodes returned by getMixinNodeTypes() must be" + "mixin", types[i].isMixin());
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class NodeDiscoveringNodeTypesTest method testGetPrimaryNodeType.
/**
* Test if getPrimaryNodeType() returns the node type according to the
* property "jcr:primaryType"
*/
public void testGetPrimaryNodeType() throws NotExecutableException, RepositoryException {
if (childNode == null) {
throw new NotExecutableException("Workspace does not have sufficient content for this test. " + "Root node must have at least one child node.");
}
NodeType type = childNode.getPrimaryNodeType();
String name = childNode.getProperty(jcrPrimaryType).getString();
assertEquals("getPrimaryNodeType() must return the node type stored " + "as property \"jcr:primaryType\"", name, type.getName());
assertFalse("getPrimaryNodeType() must return a primary node type", type.isMixin());
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class NodeIteratorTest method testGetSize.
/**
* Tests if {@link javax.jcr.NodeIterator#getSize()} returns the correct
* size.
* @throws NotExecutableException if getSize() returns -1 (unavailable).
*/
public void testGetSize() throws RepositoryException, NotExecutableException {
NodeIterator iter = testRootNode.getNodes();
long size = testRootNode.getNodes().getSize();
if (size != -1) {
long count = 0;
while (iter.hasNext()) {
iter.nextNode();
count++;
}
assertEquals("NodeIterator.getSize does not return correct number.", size, count);
} else {
throw new NotExecutableException("NodeIterator.getSize() does not return size information.");
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class XPathDocOrderTest method docOrderTest.
//-----------------------------< internal >---------------------------------
/**
* Executes a statement, checks if the Result contains exactly one node with
* <code>path</code>.
*
* @param stmt to be executed
* @param path the path of the node in the query result.
*/
private void docOrderTest(Statement stmt, String path) throws RepositoryException, NotExecutableException {
if (!isSupported(Repository.QUERY_XPATH_DOC_ORDER)) {
throw new NotExecutableException("Repository does not support document order on result set.");
}
int count = 0;
// check precondition: at least 3 nodes
for (NodeIterator it = testRootNode.getNodes(); it.hasNext(); it.nextNode()) {
count++;
}
if (count < 3) {
throw new NotExecutableException("Workspace does not contain enough content under: " + testRoot + ". At least 3 nodes are required for this test.");
}
QueryResult result = execute(stmt);
checkResult(result, 1);
assertEquals("Wrong result node.", path, result.getNodes().nextNode().getPath());
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class XPathPosIndexTest method docOrderTest.
//-----------------------------< internal >---------------------------------
/**
* Executes a statement, checks if the Result contains exactly one node with
* <code>path</code>.
*
* @param stmt to be executed
* @param path the path of the node in the query result.
*/
private void docOrderTest(Statement stmt, String path) throws RepositoryException, NotExecutableException {
if (!isSupported(Repository.QUERY_XPATH_POS_INDEX)) {
throw new NotExecutableException("Repository does not support document order on result set.");
}
int count = 0;
// check precondition: at least 3 nodes
for (NodeIterator it = testRootNode.getNodes(); it.hasNext(); it.nextNode()) {
count++;
}
if (count < 3) {
throw new NotExecutableException("Workspace does not contain enough content under: " + testRoot + ". At least 3 nodes are required for this test.");
}
QueryResult result = execute(stmt);
checkResult(result, 1);
assertEquals("Wrong result node.", path, result.getNodes().nextNode().getPath());
}
Aggregations