use of javax.jcr.version.Version 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.Version in project jackrabbit by apache.
the class VersionLabelTest method testGetVersionLabelsForVersion.
/**
* Test VersionHistory.getVersionLabels(Version) only returns all labels present
* for the specified version.
*
* @throws RepositoryException
* @see VersionHistory#getVersionLabels(javax.jcr.version.Version)
*/
@SuppressWarnings("deprecation")
public void testGetVersionLabelsForVersion() throws RepositoryException {
Set<String> testLabels = new HashSet<String>(Arrays.asList(vHistory.getVersionLabels(version)));
vHistory.addVersionLabel(version.getName(), versionLabel, false);
testLabels.add(versionLabel);
// add a version label to another version (not added to the testLabel set)
versionableNode.checkout();
Version v = versionableNode.checkin();
vHistory.addVersionLabel(v.getName(), versionLabel2, false);
String[] labels = vHistory.getVersionLabels(version);
for (int i = 0; i < labels.length; i++) {
String l = labels[i];
if (!testLabels.contains(l)) {
fail("VersionHistory.getVersionLabels(Version) must only return labels, that have been added for this version.");
}
testLabels.remove(l);
}
assertTrue("VersionHistory.getVersionLabels(Version) must return all labels, that have been added for this version.", testLabels.isEmpty());
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class RestoreTest method testRestoreSetsBaseVersionJcr2_4.
/**
* Test if restoring a node sets the jcr:baseVersion property correctly.
*
* @throws javax.jcr.RepositoryException
*/
public void testRestoreSetsBaseVersionJcr2_4() throws RepositoryException {
versionManager.restore(new Version[] { version }, true);
Version baseV = versionManager.getBaseVersion(versionableNode.getPath());
assertTrue("Restoring a node must set node's base version in order to point to the restored version.", version.isSame(baseV));
}
use of javax.jcr.version.Version 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
}
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class RestoreTest method testRestoreSetsBaseVersion.
/**
* Test if restoring a node sets the jcr:baseVersion property correctly.
*
* @throws javax.jcr.RepositoryException
*/
@SuppressWarnings("deprecation")
public void testRestoreSetsBaseVersion() throws RepositoryException {
versionableNode.restore(version, true);
Version baseV = versionableNode.getBaseVersion();
assertTrue("Restoring a node must set node's base version in order to point to the restored version.", version.isSame(baseV));
}
Aggregations