Search in sources :

Example 41 with InvalidItemStateException

use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.

the class MoveRemoveTest method moveExistingNodeRefreshParent.

@Test
public void moveExistingNodeRefreshParent() throws RepositoryException {
    Session session = getAdminSession();
    session.getRootNode().addNode("parent").addNode("new");
    session.save();
    Session session2 = createAdminSession();
    Node n2 = session2.getNode("/parent/new");
    Node n = session.getNode("/parent/new");
    session.move("/parent", "/moved");
    session.save();
    session2.refresh(false);
    try {
        n2.getPath();
        fail();
    } catch (InvalidItemStateException e) {
    }
    session.getRootNode().addNode("parent").addNode("new");
    session.save();
    session2.refresh(false);
    assertEquals("/parent/new", n2.getPath());
    session2.logout();
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) Node(javax.jcr.Node) Session(javax.jcr.Session) Test(org.junit.Test)

Example 42 with InvalidItemStateException

use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.

the class MoveRemoveTest method removeExistingNode.

@Test
public void removeExistingNode() throws RepositoryException {
    Session session = getAdminSession();
    session.getRootNode().addNode("new");
    session.save();
    Node n = session.getNode("/new");
    n.remove();
    try {
        n.getPath();
        fail();
    } catch (InvalidItemStateException e) {
    }
    session.getRootNode().addNode("new");
    assertEquals("/new", n.getPath());
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) Node(javax.jcr.Node) Session(javax.jcr.Session) Test(org.junit.Test)

Example 43 with InvalidItemStateException

use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.

the class MoveRemoveTest method removeNewNode.

@Test
public void removeNewNode() throws RepositoryException {
    Session session = getAdminSession();
    session.getRootNode().addNode("new");
    Node n = session.getNode("/new");
    n.remove();
    try {
        n.getPath();
        fail();
    } catch (InvalidItemStateException e) {
    }
    session.getRootNode().addNode("new");
    assertEquals("/new", n.getPath());
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) Node(javax.jcr.Node) Session(javax.jcr.Session) Test(org.junit.Test)

Example 44 with InvalidItemStateException

use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.

the class MoveRemoveTest method moveExistingNodeRefresh.

@Test
public void moveExistingNodeRefresh() throws RepositoryException {
    Session session = getAdminSession();
    session.getRootNode().addNode("new");
    session.save();
    Session session2 = createAdminSession();
    Node n2 = session2.getNode("/new");
    Node n = session.getNode("/new");
    session.move("/new", "/moved");
    session.save();
    session2.refresh(false);
    try {
        n2.getPath();
        fail();
    } catch (InvalidItemStateException e) {
    }
    session.getRootNode().addNode("new");
    session.save();
    session2.refresh(false);
    assertEquals("/new", n2.getPath());
    session2.logout();
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) Node(javax.jcr.Node) Session(javax.jcr.Session) Test(org.junit.Test)

Example 45 with InvalidItemStateException

use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.

the class RepositoryTest method invalidItemStateExceptionOnRemovedNode.

@Test
public void invalidItemStateExceptionOnRemovedNode() throws Exception {
    Session session = getAdminSession();
    for (String parentPath : new String[] { "/", TEST_PATH }) {
        Node parent = session.getNode(parentPath);
        Node child = parent.addNode("child");
        String childPath = child.getPath();
        child.remove();
        try {
            child.getPath();
            fail();
        } catch (InvalidItemStateException expected) {
        }
        session.save();
        try {
            child.getPath();
            fail();
        } catch (InvalidItemStateException expected) {
        }
        parent.addNode("child");
        assertEquals(childPath, child.getPath());
    }
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) JackrabbitNode(org.apache.jackrabbit.api.JackrabbitNode) Node(javax.jcr.Node) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Session(javax.jcr.Session) Test(org.junit.Test)

Aggregations

InvalidItemStateException (javax.jcr.InvalidItemStateException)100 Node (javax.jcr.Node)67 Session (javax.jcr.Session)35 Test (org.junit.Test)21 Property (javax.jcr.Property)15 RepositoryException (javax.jcr.RepositoryException)14 NodeIterator (javax.jcr.NodeIterator)5 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)5 QueryResult (javax.jcr.query.QueryResult)5 JackrabbitNode (org.apache.jackrabbit.api.JackrabbitNode)5 ItemNotFoundException (javax.jcr.ItemNotFoundException)4 NodeType (javax.jcr.nodetype.NodeType)3 SessionImpl (org.apache.jackrabbit.core.SessionImpl)3 NodeId (org.apache.jackrabbit.core.id.NodeId)3 ChildNodeEntry (org.apache.jackrabbit.core.state.ChildNodeEntry)3 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)3 NodeState (org.apache.jackrabbit.core.state.NodeState)3 PathNotFoundException (javax.jcr.PathNotFoundException)2 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)2 Version (javax.jcr.version.Version)2