use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class VersionLabelTest method testGetVersionLabelsJcr2.
/**
* Test VersionHistory.getVersionLabels() returns all labels present on the version history.
*
* @throws RepositoryException
* @see javax.jcr.version.VersionHistory#getVersionLabels()
*/
public void testGetVersionLabelsJcr2() throws RepositoryException {
Set<String> testLabels = new HashSet<String>(Arrays.asList(vHistory.getVersionLabels()));
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
versionManager.checkout(path);
Version v = versionManager.checkin(path);
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.VersionManager in project jackrabbit by apache.
the class FrozenNodeTest method testFrozenChildNodeType.
/**
* @throws RepositoryException
*/
public void testFrozenChildNodeType() throws RepositoryException {
Node n1 = versionableNode.addNode("child");
versionableNode.getSession().save();
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
Version v = versionManager.checkin(path);
Node n = v.getFrozenNode().getNode("child");
String fuuid = n.getProperty("jcr:frozenPrimaryType").getValue().getString();
String ruuid = n1.getPrimaryNodeType().getName();
assertEquals("jcr:frozenPrimaryType needs to be equal to the getPrimaryNodeType() return value.", ruuid, fuuid);
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class VersionGraphTest method testInitialBaseVersionPointsToRootVersionJcr2.
/**
* Test that the initial base version after creation of a versionable node
* points to the root version.
*
* @throws javax.jcr.RepositoryException
*/
public void testInitialBaseVersionPointsToRootVersionJcr2() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
Version rV = versionManager.getVersionHistory(path).getRootVersion();
Version bV = versionManager.getBaseVersion(path);
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.VersionManager in project jackrabbit by apache.
the class VersionHistoryTest method testInitiallyGetAllLinearVersionsContainsTheRootAndTheBaseVersion.
/**
* Test if the iterator returned by {@link javax.jcr.version.VersionHistory#getAllLinearVersions()}
* contains both the root and the base version upon creation of the version history.
* @since JCR 2.0
*/
public void testInitiallyGetAllLinearVersionsContainsTheRootAndTheBaseVersion() throws RepositoryException {
VersionManager vm = versionableNode.getSession().getWorkspace().getVersionManager();
List<String> lvh = new ArrayList<String>();
for (VersionIterator it = vHistory.getAllLinearVersions(); it.hasNext(); ) {
lvh.add(it.nextVersion().getName());
}
String rootVersion = vm.getVersionHistory(versionableNode.getPath()).getRootVersion().getName();
String baseVersion = vm.getBaseVersion(versionableNode.getPath()).getName();
assertTrue("root version " + rootVersion + " must be part of the linear version history: " + lvh, lvh.contains(rootVersion));
assertTrue("base version " + baseVersion + " must be part of the linear version history: " + lvh, lvh.contains(baseVersion));
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class WorkspaceRestoreTest method testWorkspaceRestoreOnCheckedInNodeJcr2.
/**
* Test if workspace-restoring a node works on checked-in node.
*/
public void testWorkspaceRestoreOnCheckedInNodeJcr2() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
if (versionManager.isCheckedOut(path)) {
versionManager.checkin(path);
}
superuser.getWorkspace().getVersionManager().restore(new Version[] { version }, true);
}
Aggregations