use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class SerializationTest method doTestVersioningExceptionFileChild.
public void doTestVersioningExceptionFileChild(boolean useWorkspace, boolean useHandler) throws Exception {
Node n = initVersioningException(false);
FileInputStream in = new FileInputStream(file);
try {
doImport(n.getPath(), in, useWorkspace, useHandler);
fail("Importing to a child of a checked-in node must throw a ConstraintViolationException.");
} catch (VersionException e) {
// success
} finally {
try {
in.close();
} catch (IOException ignore) {
}
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class SerializationTest method doTestVersioningExceptionFileParent.
public void doTestVersioningExceptionFileParent(boolean useWorkspace, boolean useHandler) throws Exception {
Node n = initVersioningException(true);
FileInputStream in = new FileInputStream(file);
try {
doImport(n.getPath(), in, useWorkspace, useHandler);
fail("Importing to a checked-in node must throw a ConstraintViolationException.");
} catch (VersionException e) {
// success
} finally {
try {
in.close();
} catch (IOException ignore) {
}
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class HoldTest method testRemoveHoldOnCheckedInNode.
public void testRemoveHoldOnCheckedInNode() throws NotExecutableException, RepositoryException {
Node vn = getVersionableChildNode();
vn.checkout();
Node n = vn.addNode(nodeName2);
Hold h = retentionMgr.addHold(n.getPath(), getHoldName(), false);
superuser.save();
// checkin on the parent node make the hold-containing node checked-in.
vn.checkin();
javax.jcr.Session otherS = getHelper().getSuperuserSession();
try {
RetentionManager rmgr = getRetentionManager(otherS);
Hold[] holds = rmgr.getHolds(n.getPath());
if (holds.length > 0) {
rmgr.removeHold(n.getPath(), holds[0]);
otherS.save();
fail("Removing a hold on a checked-in node must throw VersionException.");
}
} catch (VersionException e) {
// success
} finally {
otherS.logout();
// clear hold added before
vn.checkout();
try {
retentionMgr.removeHold(n.getPath(), h);
superuser.save();
} catch (RepositoryException e) {
// should not get here if test is correctly executed.
}
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class RetentionPolicyTest method testSetRetentionPolicyOnCheckedInNode.
public void testSetRetentionPolicyOnCheckedInNode() throws NotExecutableException, RepositoryException {
Node child = getVersionableChildNode();
child.checkout();
child.checkin();
String childPath = child.getPath();
// get another session.
Session otherS = getHelper().getSuperuserSession();
try {
RetentionManager rmgr = getRetentionManager(otherS);
rmgr.setRetentionPolicy(childPath, getApplicableRetentionPolicy());
otherS.save();
fail("Setting a retention policy on a checked-in node must throw VersionException.");
} catch (VersionException e) {
// success
} finally {
otherS.logout();
// clear policies (in case of test failure)
try {
retentionMgr.removeRetentionPolicy(childPath);
superuser.save();
} catch (RepositoryException e) {
// ignore.
}
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class RemoveVersionTest method testRemoveInvalidVersion.
/**
* Test if removing a version from the version history throws a VersionException
* if the specified version does not exist.
*
* @throws RepositoryException
* @throws NotExecutableException
*/
public void testRemoveInvalidVersion() throws RepositoryException, NotExecutableException {
Version invalidV = versionableNode2.checkin();
String invalidName = invalidV.getName();
// build a version name that is not present in the current history
boolean found = false;
for (int i = 0; i < 10 && !found; i++) {
try {
vHistory.getVersion(invalidName);
invalidName += i;
} catch (VersionException e) {
// ok > found a name that is invalid.
found = true;
}
}
if (!found) {
throw new NotExecutableException("Failed to create an invalid name in order to test the removal of versions.");
}
try {
vHistory.removeVersion(invalidName);
fail("Removing a version that does not exist must fail with a VersionException.");
} catch (VersionException e) {
// success
}
}
Aggregations