use of javax.jcr.retention.Hold in project jackrabbit by apache.
the class HoldTest method testHoldIsDeep.
public void testHoldIsDeep() throws RepositoryException, NotExecutableException {
Hold h = retentionMgr.addHold(testNodePath, getHoldName(), false);
assertEquals("Hold.isDeep() must reflect the specified flag.", false, h.isDeep());
}
use of javax.jcr.retention.Hold in project jackrabbit by apache.
the class HoldTest method testNonExistingNodePath.
public void testNonExistingNodePath() throws RepositoryException, NotExecutableException {
String invalidPath = testNodePath + "/nonexisting";
int cnt = 0;
while (superuser.nodeExists(invalidPath)) {
invalidPath += cnt++;
}
try {
retentionMgr.getHolds(invalidPath);
fail("Accessing holds from non-existing node must throw PathNotFoundException.");
} catch (PathNotFoundException e) {
// success
}
try {
retentionMgr.addHold(invalidPath, getHoldName(), true);
fail("Adding a hold for a non-existing node must throw PathNotFoundException.");
} catch (PathNotFoundException e) {
// success
}
try {
Hold h = retentionMgr.addHold(testNodePath, getHoldName(), true);
retentionMgr.removeHold(invalidPath, h);
fail("Removing a hold at a non-existing node must throw PathNotFoundException.");
} catch (PathNotFoundException e) {
// success
}
}
use of javax.jcr.retention.Hold in project jackrabbit by apache.
the class HoldTest method testHoldIsDeep2.
public void testHoldIsDeep2() throws RepositoryException, NotExecutableException {
Hold h = retentionMgr.addHold(testNodePath, getHoldName(), true);
assertEquals("Hold.isDeep() must reflect the specified flag.", true, h.isDeep());
}
use of javax.jcr.retention.Hold in project jackrabbit by apache.
the class HoldTest method testAddHold.
public void testAddHold() throws RepositoryException, NotExecutableException {
Hold hold = retentionMgr.addHold(testNodePath, getHoldName(), false);
Hold[] holds = retentionMgr.getHolds(testNodePath);
assertTrue("getHolds must return the hold added before.", holds.length >= 1);
assertTrue("getHolds doesn't return the hold added before", containsHold(holds, hold));
}
use of javax.jcr.retention.Hold in project jackrabbit by apache.
the class HoldTest method testRemoveHoldOnLockedNode.
public void testRemoveHoldOnLockedNode() throws NotExecutableException, RepositoryException {
Node child = getLockedChildNode();
Hold h = retentionMgr.addHold(child.getPath(), getHoldName(), false);
testRootNode.getSession().save();
javax.jcr.Session otherS = getHelper().getSuperuserSession();
try {
RetentionManager rmgr = getRetentionManager(otherS);
Hold[] holds = rmgr.getHolds(child.getPath());
if (holds.length > 0) {
rmgr.removeHold(child.getPath(), holds[0]);
otherS.save();
fail("Removing a hold on a locked node must throw LockException.");
}
} catch (LockException e) {
// success
} finally {
otherS.logout();
// clear hold added before
try {
retentionMgr.removeHold(child.getPath(), h);
superuser.save();
} catch (RepositoryException e) {
// should not get here if test is correctly executed.
}
}
}
Aggregations