Search in sources :

Example 21 with Hold

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());
}
Also used : Hold(javax.jcr.retention.Hold)

Example 22 with Hold

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
    }
}
Also used : PathNotFoundException(javax.jcr.PathNotFoundException) Hold(javax.jcr.retention.Hold)

Example 23 with Hold

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());
}
Also used : Hold(javax.jcr.retention.Hold)

Example 24 with Hold

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));
}
Also used : Hold(javax.jcr.retention.Hold)

Example 25 with 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.
        }
    }
}
Also used : RetentionManager(javax.jcr.retention.RetentionManager) LockException(javax.jcr.lock.LockException) Node(javax.jcr.Node) RepositoryException(javax.jcr.RepositoryException) Hold(javax.jcr.retention.Hold)

Aggregations

Hold (javax.jcr.retention.Hold)26 RepositoryException (javax.jcr.RepositoryException)9 Node (javax.jcr.Node)4 RetentionManager (javax.jcr.retention.RetentionManager)4 RetentionRegistry (org.apache.jackrabbit.core.retention.RetentionRegistry)3 PathNotFoundException (javax.jcr.PathNotFoundException)2 LockException (javax.jcr.lock.LockException)2 VersionException (javax.jcr.version.VersionException)2 ArrayList (java.util.ArrayList)1 PropertyIterator (javax.jcr.PropertyIterator)1 NodeImpl (org.apache.jackrabbit.core.NodeImpl)1 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)1