Search in sources :

Example 41 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class ReorderTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    if (!testRootNode.getPrimaryNodeType().hasOrderableChildNodes()) {
        throw new NotExecutableException("Test node does not have orderable children.");
    }
    NodeIterator it = testRootNode.getNodes();
    if (it.hasNext()) {
        throw new NotExecutableException("Test node already contains child nodes");
    }
    createOrderableChildren();
}
Also used : NodeIterator(javax.jcr.NodeIterator) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

Example 42 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class SingleValuedPropertyTest method testGetLengthsFromSingleValued.

/**
     * Tests if Property.getLengths() fails for single value property.
     */
public void testGetLengthsFromSingleValued() throws RepositoryException, NotExecutableException {
    Property singleProp = PropertyUtil.searchSingleValuedProperty(testRootNode);
    if (singleProp == null) {
        throw new NotExecutableException("No single valued property found.");
    }
    try {
        singleProp.getLengths();
        fail("Property.getLengths() called on a single value property must fail (ValueFormatException).");
    } catch (ValueFormatException vfe) {
    // ok
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Example 43 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class MoveTest method testAccessMovedNodeByOldPath.

/**
     * Test if a moved node is not accessible by its old path any more
     */
public void testAccessMovedNodeByOldPath() throws RepositoryException, NotExecutableException {
    NodeIterator it = srcParentNode.getNodes(moveNode.getName());
    int cnt = 0;
    while (it.hasNext()) {
        it.nextNode();
        cnt++;
    }
    if (cnt > 1) {
        throw new NotExecutableException("Move source parent has multiple child nodes with name " + moveNode.getName());
    }
    String oldPath = moveNode.getPath();
    //move the node
    doMove(oldPath, destinationPath);
    try {
        superuser.getItem(oldPath);
        fail("A moved node must not be accessible by its old path any more.");
    } catch (PathNotFoundException e) {
    // ok.
    }
}
Also used : NodeIterator(javax.jcr.NodeIterator) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) PathNotFoundException(javax.jcr.PathNotFoundException)

Example 44 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class MoveTest method testAccessMovedNodeByOldPath2.

/**
     * Same as {@link #testAccessMovedNodeByOldPath()} but calls save() prior to
     * the test.
     */
public void testAccessMovedNodeByOldPath2() throws RepositoryException, NotExecutableException {
    NodeIterator it = srcParentNode.getNodes(moveNode.getName());
    int cnt = 0;
    while (it.hasNext()) {
        it.nextNode();
        cnt++;
    }
    if (cnt > 1) {
        throw new NotExecutableException("Move source parent has multiple child nodes with name " + moveNode.getName());
    }
    String oldPath = moveNode.getPath();
    //move the node
    doMove(oldPath, destinationPath);
    superuser.save();
    try {
        superuser.getItem(oldPath);
        fail("A moved node must not be accessible by its old path any more.");
    } catch (PathNotFoundException e) {
    // ok.
    }
}
Also used : NodeIterator(javax.jcr.NodeIterator) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) PathNotFoundException(javax.jcr.PathNotFoundException)

Example 45 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class MoveTest method testMovePropertyExists.

/**
     * Tries to move a node using <code>{@link javax.jcr.Session#move(String src, String dest)}
     * </code> to a location where a property already exists with same name.
     * <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.
     */
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");
    } 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 {
        // move the node: same name property and node must be supported
        // see Issue 725
        doMove(moveNode.getPath(), destProperty.getPath());
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) ItemExistsException(javax.jcr.ItemExistsException) RepositoryException(javax.jcr.RepositoryException) Property(javax.jcr.Property)

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