use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class CRUDTest method testRemoveMissingProperty.
@Test
public void testRemoveMissingProperty() throws RepositoryException {
Session session = getAdminSession();
Node root = session.getRootNode();
Property p = root.setProperty("missing", (String) null);
assertNotNull(p);
try {
p.getValue();
fail("must throw InvalidItemStateException");
} catch (InvalidItemStateException e) {
// expected
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class CompatibilityIssuesTest method move.
@Test
public void move() throws RepositoryException {
Session session = getAdminSession();
Node node = session.getNode("/");
node.addNode("source").addNode("node");
node.addNode("target");
session.save();
session.refresh(true);
Node sourceNode = session.getNode("/source/node");
session.move("/source/node", "/target/moved");
// assertEquals("/target/moved", sourceNode.getPath()); // passes on JR2, fails on Oak
try {
sourceNode.getPath();
} catch (InvalidItemStateException expected) {
// sourceNode is stale
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class CRUDTest method checkPathInInvalidItemStateException.
@Test
public void checkPathInInvalidItemStateException() throws Exception {
Session s1 = getAdminSession();
Node root = s1.getRootNode();
Node a = root.addNode("a");
String path = a.getPath();
s1.save();
Session s2 = getAdminSession();
s2.getRootNode().getNode("a").remove();
s2.save();
s1.refresh(false);
try {
a.getPath();
} catch (InvalidItemStateException e) {
assertThat(e.getMessage(), containsString(path));
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class CRUDTest method testRemoveMissingMVProperty.
@Test
public void testRemoveMissingMVProperty() throws RepositoryException {
Session session = getAdminSession();
Node root = session.getRootNode();
Property p = root.setProperty("missing", (String[]) null);
assertNotNull(p);
try {
p.getValues();
fail("must throw InvalidItemStateException");
} catch (InvalidItemStateException e) {
// expected
}
}
use of javax.jcr.InvalidItemStateException in project jackrabbit-oak by apache.
the class MoveRemoveTest method removeNewNodeParent.
@Test
public void removeNewNodeParent() throws RepositoryException {
Session session = getAdminSession();
session.getRootNode().addNode("parent").addNode("new");
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());
}
Aggregations