use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class MoveRemoveTest method removeExistingNodeParent.
@Test
public void removeExistingNodeParent() throws RepositoryException {
Session session = getAdminSession();
session.getRootNode().addNode("parent").addNode("new");
session.save();
Node n = session.getNode("/parent/new");
n.getParent().remove();
try {
n.getPath();
fail();
} catch (InvalidItemStateException e) {
}
session.getRootNode().addNode("parent").addNode("new");
assertEquals("/parent/new", n.getPath());
}
use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class MoveRemoveTest method removeExistingNodeRefreshParent.
@Test
public void removeExistingNodeRefreshParent() 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");
n.getParent().remove();
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();
}
use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class RepositoryTest method removeNode.
@Test
public void removeNode() throws RepositoryException {
Node parentNode = getNode(TEST_PATH);
parentNode.addNode("newNode");
parentNode.getSession().save();
Session session2 = createAdminSession();
try {
Node removeNode = session2.getNode(TEST_PATH + "/newNode");
removeNode.remove();
try {
removeNode.getParent();
fail("Cannot retrieve the parent from a transiently removed item.");
} catch (InvalidItemStateException expected) {
}
assertTrue(session2.getNode(TEST_PATH).isModified());
session2.save();
} finally {
session2.logout();
}
Session session3 = createAnonymousSession();
try {
assertFalse(session3.nodeExists(TEST_PATH + "/newNode"));
assertFalse(session3.getNode(TEST_PATH).isModified());
} finally {
session3.logout();
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class RepositoryTest method accessRemovedItem.
@Test
public void accessRemovedItem() throws RepositoryException {
Node foo = getNode("/foo");
Node bar = foo.addNode("bar");
Property p = bar.setProperty("name", "value");
foo.remove();
try {
bar.getPath();
fail("Expected InvalidItemStateException");
} catch (InvalidItemStateException expected) {
}
try {
p.getPath();
fail("Expected InvalidItemStateException");
} catch (InvalidItemStateException expected) {
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class RepositoryTest method removeNode2.
@Test
public void removeNode2() throws RepositoryException {
Node foo = getNode("/foo");
getAdminSession().removeItem(foo.getPath());
try {
foo.getParent();
fail("Cannot retrieve the parent from a transiently removed item.");
} catch (InvalidItemStateException e) {
// success
}
}
Aggregations