use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class HoldEffectTest method assertEffect.
private void assertEffect(Node targetNode, String childName, String propName, String childName2, String propName2) throws RepositoryException {
Session s = targetNode.getSession();
try {
Node child = targetNode.getNode(childName);
child.remove();
s.save();
fail("Hold present must prevent a child node from being removed.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
Property p = targetNode.getProperty(propName);
p.remove();
s.save();
fail("Hold present must prevent a child property from being removed.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
Property p = targetNode.getProperty(propName);
p.setValue("test2");
s.save();
fail("Hold present must prevent the child property from being modified.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
targetNode.addNode(childName2);
s.save();
fail("Hold present must prevent the target node from having new nodes added.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
try {
Value v = getJcrValue(s, RepositoryStub.PROP_PROP_VALUE2, RepositoryStub.PROP_PROP_TYPE2, "test");
targetNode.setProperty(propName2, v);
s.save();
fail("Hold present must prevent the target node from having new properties set.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
NodeType[] mixins = targetNode.getMixinNodeTypes();
if (mixins.length > 0) {
try {
targetNode.removeMixin(mixins[0].getName());
s.save();
fail("Hold present must prevent the target node from having it's mixin types changed.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
}
try {
targetNode.remove();
s.save();
fail("Hold present must prevent the target node from being removed.");
} catch (RepositoryException e) {
// success
s.refresh(false);
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class HoldTest method testInvalidPath.
public void testInvalidPath() throws RepositoryException, NotExecutableException {
// not an absolute path.
String invalidPath = testPath;
try {
retentionMgr.getHolds(invalidPath);
fail("Accessing holds an invalid path must throw RepositoryException.");
} catch (RepositoryException e) {
// success
}
try {
retentionMgr.addHold(invalidPath, getHoldName(), true);
fail("Adding a hold at an invalid path must throw RepositoryException.");
} catch (RepositoryException e) {
// success
}
try {
Hold h = retentionMgr.addHold(testNodePath, getHoldName(), true);
retentionMgr.removeHold(invalidPath, h);
fail("Removing a hold at an invalid path must throw RepositoryException.");
} catch (RepositoryException e) {
// success
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class HoldTest method testRemoveHoldFromChild.
public void testRemoveHoldFromChild() throws RepositoryException, NotExecutableException {
String childPath = testRootNode.addNode(nodeName2, testNodeType).getPath();
Hold hold = retentionMgr.addHold(testNodePath, getHoldName(), false);
try {
retentionMgr.removeHold(childPath, hold);
fail("Removing hold from another node must fail");
} catch (RepositoryException e) {
// success
assertTrue(containsHold(retentionMgr.getHolds(testNodePath), hold));
}
// check again with persisted hold
superuser.save();
try {
retentionMgr.removeHold(childPath, hold);
fail("Removing hold from another node must fail");
} catch (RepositoryException e) {
// success
assertTrue(containsHold(retentionMgr.getHolds(testNodePath), hold));
} finally {
// clear the hold that was permanently added before.
retentionMgr.removeHold(testNodePath, hold);
superuser.save();
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class SelectorTest method testSelector.
public void testSelector() throws RepositoryException {
// make sure there's at least one node with this node type
testRootNode.addNode(nodeName1, testNodeType);
superuser.save();
QueryObjectModel qom = qf.createQuery(qf.selector(testNodeType, "s"), null, null, null);
forQOMandSQL2(qom, new Callable() {
public Object call(Query query) throws RepositoryException {
QueryResult result = query.execute();
String[] names = result.getSelectorNames();
assertNotNull(names);
assertEquals(1, names.length);
assertEquals("s", names[0]);
NodeIterator it = result.getNodes();
while (it.hasNext()) {
assertTrue("Wrong node type", it.nextNode().isNodeType(testNodeType));
}
return null;
}
});
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class RestoreTest method testRestoreChild1Jcr2.
public void testRestoreChild1Jcr2() throws RepositoryException {
versionableNode.addNode("child1");
versionableNode.getSession().save();
Version v1 = versionManager.checkin(versionableNode.getPath());
versionManager.checkout(versionableNode.getPath());
Version v2 = versionManager.checkin(versionableNode.getPath());
versionManager.restore(v1, true);
assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
versionManager.restore(version, true);
assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
try {
versionManager.restore(v2, true);
} catch (RepositoryException e) {
fail("Node.restore('1.3') must fail.");
}
}
Aggregations