use of javax.jcr.retention.Hold in project jackrabbit by apache.
the class HoldTest method testPropertyPath.
public void testPropertyPath() throws RepositoryException, NotExecutableException {
String propPath = null;
for (PropertyIterator it = testRootNode.getProperties(); it.hasNext(); ) {
String path = it.nextProperty().getPath();
if (!superuser.nodeExists(path)) {
propPath = path;
break;
}
}
if (propPath == null) {
throw new NotExecutableException();
}
try {
retentionMgr.getHolds(propPath);
fail("Accessing holds from non-existing node must throw PathNotFoundException.");
} catch (PathNotFoundException e) {
// success
}
try {
retentionMgr.addHold(propPath, 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(propPath, 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 testHoldGetName2.
public void testHoldGetName2() throws RepositoryException, NotExecutableException {
String holdName = getHoldName();
Hold h = retentionMgr.addHold(testNodePath, getHoldName(), true);
assertEquals("Hold.getName() must return the specified name.", holdName, h.getName());
}
use of javax.jcr.retention.Hold 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.retention.Hold in project jackrabbit by apache.
the class HoldTest method testAddHoldIsTransient.
public void testAddHoldIsTransient() throws RepositoryException, NotExecutableException {
Hold hold = retentionMgr.addHold(testNodePath, getHoldName(), false);
Hold[] holds = retentionMgr.getHolds(testNodePath);
// revert the changes made
superuser.refresh(false);
Hold[] holds2 = retentionMgr.getHolds(testNodePath);
assertEquals("Reverting transient changes must revert the hold added.", holds.length - 1, holds2.length);
assertFalse("Reverting transient changes must revert the hold added.", containsHold(holds2, hold));
}
use of javax.jcr.retention.Hold 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();
}
}
Aggregations