use of javax.jcr.version.Version in project jackrabbit by apache.
the class VersionLabelTest method testGetVersionLabels.
/**
* Test VersionHistory.getVersionLabels() returns all labels present on the version history.
*
* @throws RepositoryException
* @see javax.jcr.version.VersionHistory#getVersionLabels()
*/
@SuppressWarnings("deprecation")
public void testGetVersionLabels() throws RepositoryException {
Set<String> testLabels = new HashSet<String>(Arrays.asList(vHistory.getVersionLabels()));
versionableNode.checkout();
Version v = versionableNode.checkin();
vHistory.addVersionLabel(v.getName(), versionLabel, false);
testLabels.add(versionLabel);
vHistory.addVersionLabel(version.getName(), versionLabel2, false);
testLabels.add(versionLabel2);
String[] labels = vHistory.getVersionLabels();
for (int i = 0; i < labels.length; i++) {
String l = labels[i];
if (!testLabels.contains(l)) {
fail("VersionHistory.getVersionLabels() must only return labels, that have been added to the history.");
}
testLabels.remove(l);
}
assertTrue("VersionHistory.getVersionLabels() must return all labels, that have been added to the history.", testLabels.isEmpty());
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class VersionGraphTest method testInitialNodePredecessors.
/**
* Test if after creation of a versionable node N the multi-value
* REFERENCE property jcr:predecessors of N is initialized to contain a
* single UUID, that of the root version (the same as jcr:baseVersion).
*
* @throws RepositoryException
*/
public void testInitialNodePredecessors() throws RepositoryException {
Property predecessors = versionableNode.getProperty(jcrPredecessors);
Value[] values = predecessors.getValues();
Version rV = versionableNode.getVersionHistory().getRootVersion();
if (values.length != 1) {
fail("The jcr:predecessors property of a versionable node must be initialized to contain a single value");
}
Value initialVal = values[0];
assertTrue("The jcr:predecessors property of a versionable node is initialized to contain a single UUID, that of the root version", initialVal.equals(superuser.getValueFactory().createValue(rV)));
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class VersionGraphTest method testInitialBaseVersionPointsToRootVersion.
/**
* Test that the initial base version after creation of a versionable node
* points to the root version.
*
* @throws javax.jcr.RepositoryException
*/
public void testInitialBaseVersionPointsToRootVersion() throws RepositoryException {
Version rV = versionableNode.getVersionHistory().getRootVersion();
Version bV = versionableNode.getBaseVersion();
assertTrue("After creation of a versionable node the node's baseVersion must point to the rootVersion in the version history.", rV.isSame(bV));
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class VersionHistoryTest method testGetAllVersionsJcr2.
/**
* Test that {@link VersionHistory#getAllVersions()} returns an iterator
* containing the root version and all versions that have been created by
* Node.checkin().
*
* @see javax.jcr.version.VersionHistory#getAllVersions()
*/
public void testGetAllVersionsJcr2() throws RepositoryException {
int cnt = 5;
Map<String, Version> versions = new HashMap<String, Version>();
List<String> vnames = new ArrayList<String>();
Version v = vHistory.getRootVersion();
versions.put(v.getIdentifier(), v);
vnames.add(v.getIdentifier());
for (int i = 0; i < cnt; i++) {
v = versionManager.checkin(versionableNode.getPath());
vnames.add(v.getIdentifier());
versions.put(v.getIdentifier(), v);
versionManager.checkout(versionableNode.getPath());
}
VersionIterator it = vHistory.getAllVersions();
while (it.hasNext()) {
v = it.nextVersion();
if (!versions.containsKey(v.getIdentifier())) {
fail("VersionHistory.getAllVersions() must only contain the root version and versions, that have been created by a Node.checkin() call.");
}
versions.remove(v.getIdentifier());
// check order of linear version history (see JCR 2.0, 15.1.1.2)
assertEquals("versions in a linear version history should be sorted by creation time", vnames.remove(0), v.getIdentifier());
}
assertTrue("VersionHistory.getAllVersions() must only contain the root version and all versions that have been created with a Node.checkin() call.", versions.isEmpty());
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class OnParentVersionComputeTest method testRestorePropJcr2.
/**
* Test the restore of a OnParentVersion-COMPUTE property
*
* @throws javax.jcr.RepositoryException
*/
public void testRestorePropJcr2() throws RepositoryException {
Node propParent = p.getParent();
VersionManager versionManager = propParent.getSession().getWorkspace().getVersionManager();
String path = propParent.getPath();
versionManager.checkout(path);
Version v = versionManager.checkin(path);
versionManager.checkout(path);
p.setValue(newPropValue);
p.getSession().save();
versionManager.restore(v, false);
assertEquals("On restore of a OnParentVersion-COMPUTE property P, the current P in the workspace will be left unchanged.", p.getString(), newPropValue);
}
Aggregations