Search in sources :

Example 46 with PathNotFoundException

use of javax.jcr.PathNotFoundException 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 47 with PathNotFoundException

use of javax.jcr.PathNotFoundException 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 48 with PathNotFoundException

use of javax.jcr.PathNotFoundException in project jackrabbit by apache.

the class RemoveSNSTest method testRemoveFirstSibling3.

/**
     * Transiently removes a persisted item using {@link javax.jcr.Item#remove()}
     * and test, whether the successor sibling is returned when retrieving the
     * item with the path of the removed node.
     */
public void testRemoveFirstSibling3() throws RepositoryException {
    firstSiblingNode.remove();
    // check if the node has been properly removed
    try {
        Item secondSibling = superuser.getItem(firstSiblingPath);
        // implementation specific:
        assertTrue("", removeItem.isSame(secondSibling));
    } catch (PathNotFoundException e) {
        fail("Removing a SNS Node -> successor must be accessible from the session by removed path.");
    }
}
Also used : Item(javax.jcr.Item) PathNotFoundException(javax.jcr.PathNotFoundException)

Example 49 with PathNotFoundException

use of javax.jcr.PathNotFoundException in project jackrabbit by apache.

the class RemoveSNSTest method testRemoveFirstSibling.

/**
     * Transiently removes the first SNS-node using {@link javax.jcr.Node#remove()}
     * and test, whether the remaining sibling 'replaces' the removed node and
     * is the same as the node added as second sibling.
     */
public void testRemoveFirstSibling() throws RepositoryException {
    firstSiblingNode.remove();
    // check if the node has been properly removed
    try {
        Node secondSibling = testRootNode.getNode(nodeName1);
        // implementation specific:
        assertTrue("", removeItem.isSame(secondSibling));
    } catch (PathNotFoundException e) {
        fail("Second sibling must still be available.");
    }
}
Also used : Node(javax.jcr.Node) PathNotFoundException(javax.jcr.PathNotFoundException)

Example 50 with PathNotFoundException

use of javax.jcr.PathNotFoundException in project jackrabbit by apache.

the class RemoveSNSTest method testRemoveFirstSibling2.

/**
     * Same as {@link #testRemoveNode()}, but calls save() (persisting the removal)
     * before executing the test.
     */
public void testRemoveFirstSibling2() throws RepositoryException, NotExecutableException {
    firstSiblingNode.remove();
    testRootNode.save();
    // check if the node has been properly removed
    try {
        Node secondSibling = testRootNode.getNode(nodeName1);
        // implementation specific:
        assertTrue("", removeItem.isSame(secondSibling));
    } catch (PathNotFoundException e) {
        fail("Second sibling must still be available.");
    }
}
Also used : Node(javax.jcr.Node) PathNotFoundException(javax.jcr.PathNotFoundException)

Aggregations

PathNotFoundException (javax.jcr.PathNotFoundException)136 Node (javax.jcr.Node)58 RepositoryException (javax.jcr.RepositoryException)46 ItemNotFoundException (javax.jcr.ItemNotFoundException)24 Session (javax.jcr.Session)23 Path (org.apache.jackrabbit.spi.Path)22 AccessDeniedException (javax.jcr.AccessDeniedException)14 Property (javax.jcr.Property)14 Test (org.junit.Test)14 Item (javax.jcr.Item)11 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)10 NodeIterator (javax.jcr.NodeIterator)9 Value (javax.jcr.Value)9 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)9 Name (org.apache.jackrabbit.spi.Name)8 PropertyIterator (javax.jcr.PropertyIterator)7 NodeDelegate (org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate)7 HashSet (java.util.HashSet)6 ItemExistsException (javax.jcr.ItemExistsException)6 ValueFormatException (javax.jcr.ValueFormatException)6