use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class RestoreTest method testRestoreWithInvalidVersionJcr2.
/**
* Test if restoring a node with an invalid Version throws a VersionException
*
* @throws RepositoryException
*/
public void testRestoreWithInvalidVersionJcr2() throws RepositoryException {
Version invalidVersion = versionManager.checkin(versionableNode2.getPath());
try {
versionManager.restore(versionableNode.getPath(), invalidVersion, true);
fail("Node.restore(Version, boolean): A VersionException must be thrown if the specified version does not exists in this node's version history.");
} catch (VersionException e) {
// success
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class VersionLabelTest method testMoveLabelJcr2.
/**
* Test if the 'moveLabel' flag moves an existing version label.
*
* @throws RepositoryException
* @see VersionHistory#addVersionLabel(String, String, boolean) with boolan flag equals true.
*/
public void testMoveLabelJcr2() throws RepositoryException {
vHistory.addVersionLabel(version.getName(), versionLabel, false);
try {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
versionManager.checkout(path);
Version v = versionManager.checkin(path);
vHistory.addVersionLabel(v.getName(), versionLabel, true);
if (!vHistory.hasVersionLabel(v, versionLabel)) {
fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
}
} catch (VersionException e) {
fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class VersionLabelTest method testMoveLabel.
/**
* Test if the 'moveLabel' flag moves an existing version label.
*
* @throws RepositoryException
* @see VersionHistory#addVersionLabel(String, String, boolean) with boolan flag equals true.
*/
@SuppressWarnings("deprecation")
public void testMoveLabel() throws RepositoryException {
vHistory.addVersionLabel(version.getName(), versionLabel, false);
try {
versionableNode.checkout();
Version v = versionableNode.checkin();
vHistory.addVersionLabel(v.getName(), versionLabel, true);
if (!vHistory.hasVersionLabel(v, versionLabel)) {
fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
}
} catch (VersionException e) {
fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class SessionMoveVersionExceptionTest method testSessionMoveSourceCheckedInVersionException.
/**
* Tries to move a node using {@link javax.jcr.Session#move(String, String)}
* where the source parent is checked in. This should throw an {@link
* javax.jcr.version.VersionException}.
*/
public void testSessionMoveSourceCheckedInVersionException() throws RepositoryException {
// add a node under a versionable node
Node movingNode = versionableNode.addNode(nodeName1, nonVersionableNodeType.getName());
versionableNode.save();
// check the parent node in
versionableNode.checkin();
try {
// try to move the sub node this should throw an VersionException
// either instantly or upon save()
superuser.move(movingNode.getPath(), nonVersionableNode.getPath() + "/" + nodeName1);
superuser.save();
fail("Moving a node using Session.move() where parent node is " + "versionable and checked in should throw a VersionException!");
} catch (VersionException e) {
// ok, works as expected
}
}
use of javax.jcr.version.VersionException in project jackrabbit by apache.
the class VersionLabelTest method testAddDuplicateVersionLabelJcr2.
/**
* Test if VersionHistory.addVersionLabel(versionName, label, moveLabel)
* throws VersionException the label already exists and if moveLabel is false)
*
* @throws RepositoryException
*/
public void testAddDuplicateVersionLabelJcr2() throws RepositoryException {
vHistory.addVersionLabel(version.getName(), versionLabel, false);
try {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
versionManager.checkout(path);
Version v = versionManager.checkin(path);
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
}
}
Aggregations