Search in sources :

Example 6 with Hold

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
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) PropertyIterator(javax.jcr.PropertyIterator) PathNotFoundException(javax.jcr.PathNotFoundException) Hold(javax.jcr.retention.Hold)

Example 7 with Hold

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

Example 8 with Hold

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

Example 9 with Hold

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

Example 10 with 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();
    }
}
Also used : 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