Search in sources :

Example 61 with NotExecutableException

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());
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node) NodeType(javax.jcr.nodetype.NodeType) Value(javax.jcr.Value)

Example 62 with NotExecutableException

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());
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) NodeType(javax.jcr.nodetype.NodeType)

Example 63 with NotExecutableException

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.");
    }
}
Also used : NodeIterator(javax.jcr.NodeIterator) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

Example 64 with NotExecutableException

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());
}
Also used : NodeIterator(javax.jcr.NodeIterator) QueryResult(javax.jcr.query.QueryResult) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

Example 65 with NotExecutableException

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());
}
Also used : NodeIterator(javax.jcr.NodeIterator) QueryResult(javax.jcr.query.QueryResult) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

Aggregations

NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)381 Node (javax.jcr.Node)149 NodeType (javax.jcr.nodetype.NodeType)84 Value (javax.jcr.Value)81 RepositoryException (javax.jcr.RepositoryException)64 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)61 Session (javax.jcr.Session)59 Property (javax.jcr.Property)47 NodeDefinition (javax.jcr.nodetype.NodeDefinition)29 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)28 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)25 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)23 AccessControlPolicyIterator (javax.jcr.security.AccessControlPolicyIterator)22 Test (org.junit.Test)22 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)21 User (org.apache.jackrabbit.api.security.user.User)19 Principal (java.security.Principal)18 NodeIterator (javax.jcr.NodeIterator)18 UserManager (org.apache.jackrabbit.api.security.user.UserManager)17 ItemExistsException (javax.jcr.ItemExistsException)16