Search in sources :

Example 61 with InvalidItemStateException

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

the class ConcurrentAddRemovePropertyTest method testAddSameName.

public void testAddSameName() throws Exception {
    Node n = testRootNode.addNode(nodeName1);
    superuser.save();
    n.setProperty(propertyName1, "foo");
    session.getNode(testRoot).getNode(nodeName1).setProperty(propertyName1, "bar");
    superuser.save();
    try {
        session.save();
    } catch (InvalidItemStateException e) {
        fail("must not throw InvalidItemStateException");
    }
    assertEquals("bar", n.getProperty(propertyName1).getString());
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) Node(javax.jcr.Node)

Example 62 with InvalidItemStateException

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

the class ConcurrentAddRemovePropertyTest method testRemoveSameName.

public void testRemoveSameName() throws Exception {
    Node n = testRootNode.addNode(nodeName1);
    n.setProperty(propertyName1, "foo");
    superuser.save();
    n.getProperty(propertyName1).remove();
    session.getNode(testRoot).getNode(nodeName1).getProperty(propertyName1).remove();
    superuser.save();
    try {
        session.save();
    } catch (InvalidItemStateException e) {
        fail("must not throw InvalidItemStateException");
    }
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) Node(javax.jcr.Node)

Example 63 with InvalidItemStateException

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

the class ConcurrentCyclicMoveTest method testConcurrentSessionMove.

public void testConcurrentSessionMove() throws RepositoryException {
    testRootPath = testRootNode.getPath();
    Node aa = testRootNode.addNode("a").addNode("aa");
    Node b = testRootNode.addNode("b");
    testRootNode.getSession().save();
    String aaId = aa.getIdentifier();
    String bId = b.getIdentifier();
    Session session1 = getHelper().getReadWriteSession();
    Session session2 = getHelper().getReadWriteSession();
    // results in /b/a/aa
    session1.move(testRootPath + "/a", testRootPath + "/b/a");
    assertEquals(testRootPath + "/b/a/aa", session1.getNodeByIdentifier(aaId).getPath());
    // results in a/aa/b
    session2.move(testRootPath + "/b", testRootPath + "/a/aa/b");
    assertEquals(testRootPath + "/a/aa/b", session2.getNodeByIdentifier(bId).getPath());
    session1.save();
    try {
        session2.getNodeByIdentifier(bId).getPath();
        fail("It should not be possible to access a cyclic path");
    } catch (InvalidItemStateException expected) {
    }
    try {
        session2.save();
        fail("Save should have failed. Possible cyclic persistent path created.");
    } catch (InvalidItemStateException expected) {
    }
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) Node(javax.jcr.Node) Session(javax.jcr.Session)

Example 64 with InvalidItemStateException

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

the class ConcurrentMixinModificationTest method testMixin.

public void testMixin() throws Exception {
    Node n = testRootNode.addNode(nodeName1);
    superuser.save();
    n.addMixin(mixReferenceable);
    session.getNode(testRoot).getNode(nodeName1).addMixin(mixLockable);
    superuser.save();
    try {
        session.save();
        fail("InvalidItemStateException expected");
    } catch (InvalidItemStateException e) {
    // expected
    }
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) Node(javax.jcr.Node)

Example 65 with InvalidItemStateException

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

the class ConcurrentModificationWithSNSTest method testSNSNotAllowed.

public void testSNSNotAllowed() throws Exception {
    cleanUpTestRoot(superuser);
    Node f = testRootNode.addNode("folder", "nt:folder");
    superuser.save();
    f.addNode("A", "nt:folder");
    session.getNode(f.getPath()).addNode("A", "nt:folder");
    superuser.save();
    try {
        session.save();
        fail("InvalidItemStateException expected");
    } catch (InvalidItemStateException e) {
    // expected
    }
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) Node(javax.jcr.Node)

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