Search in sources :

Example 36 with NotExecutableException

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

Example 37 with NotExecutableException

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

Example 38 with NotExecutableException

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

Example 39 with NotExecutableException

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();
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) Node(javax.jcr.Node) RepositoryException(javax.jcr.RepositoryException) Session(javax.jcr.Session)

Example 40 with NotExecutableException

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