use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class HoldTest method testAddHoldOnCheckedInNode.
public void testAddHoldOnCheckedInNode() throws NotExecutableException, RepositoryException {
Node child = getVersionableChildNode();
child.checkout();
child.checkin();
// get another session.
javax.jcr.Session otherS = getHelper().getSuperuserSession();
try {
RetentionManager rmgr = getRetentionManager(otherS);
rmgr.addHold(child.getPath(), getHoldName(), false);
otherS.save();
fail("Adding hold on a checked-in node must throw VersionException.");
} catch (VersionException e) {
// success
} finally {
otherS.logout();
// clear holds (in case of test failure)
child.checkout();
Hold[] holds = retentionMgr.getHolds(child.getPath());
for (int i = 0; i < holds.length; i++) {
retentionMgr.removeHold(child.getPath(), holds[i]);
}
superuser.save();
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class OnParentVersionAbortTest method testRestorePropJcr2.
/**
* Test the restore of a OnParentVersion-ABORT property
*
* @throws javax.jcr.RepositoryException
*/
public void testRestorePropJcr2() throws RepositoryException {
try {
VersionManager versionManager = p.getSession().getWorkspace().getVersionManager();
String path = p.getParent().getPath();
versionManager.checkout(path);
versionManager.checkin(path);
fail("On checkin of N which has a property with OnParentVersion ABORT defined, an UnsupportedRepositoryOperationException must be thrown.");
} catch (VersionException e) {
// success
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class VersionLabelTest method testGetVersionLabelsForInvalidVersion.
/**
* Test if versionHistory.getVersionLabels(Version) throws a VersionException if the
* specified version is not in this version history.
*/
public void testGetVersionLabelsForInvalidVersion() throws Exception {
// build a second versionable node below the testroot to get it's version.
Node versionableNode2 = createVersionableNode(testRootNode, nodeName2, versionableNodeType);
Version invalidV = versionableNode2.checkin();
try {
vHistory.getVersionLabels(invalidV);
fail("VersionHistory.getVersionLabels(Version) must throw a VersionException if the specified version is not in this version history");
} catch (VersionException ve) {
// success
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class VersionLabelTest method testAddDuplicateVersionLabel.
/**
* Test if VersionHistory.addVersionLabel(versionName, label, moveLabel)
* throws VersionException the label already exists and if moveLabel is false)
*
* @throws RepositoryException
*/
@SuppressWarnings("deprecation")
public void testAddDuplicateVersionLabel() throws RepositoryException {
vHistory.addVersionLabel(version.getName(), versionLabel, false);
try {
versionableNode.checkout();
Version v = versionableNode.checkin();
vHistory.addVersionLabel(v.getName(), versionLabel, false);
fail("Adding a version label that already exist in the version history must throw a VersionException.");
} catch (VersionException e) {
//success
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class RestoreTest method testRestoreInvalidVersion2Jcr2.
/**
* VersionException expected on Node.restore(String, boolean) if the specified version is not part of this node's version history.
*
* @throws RepositoryException
*/
public void testRestoreInvalidVersion2Jcr2() throws RepositoryException {
String invalidName;
do {
invalidName = createRandomString(3);
for (VersionIterator it = versionManager.getVersionHistory(versionableNode.getPath()).getAllVersions(); it.hasNext(); ) {
Version v = it.nextVersion();
if (invalidName.equals(v.getName())) {
invalidName = null;
break;
}
}
} while (invalidName == null);
try {
versionManager.restore(versionableNode.getPath(), invalidName, true);
fail("VersionException expected on Node.restore(String, boolean) if the specified version is not part of this node's version history.");
} catch (VersionException e) {
// ok
}
}
Aggregations