use of javax.jcr.version.VersionManager 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);
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class MergeSubNodeTest method setUp.
protected void setUp() throws Exception {
super.setUp();
nodeToMerge = testRootNodeW2.getNode(nodeName1);
// node has to be checked out while merging
VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
versionManager.checkout(nodeToMerge.getPath());
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class VersionLabelTest method setUp.
protected void setUp() throws Exception {
super.setUp();
jcrVersionLabels = superuser.getNamespacePrefix(NS_JCR_URI) + ":versionLabels";
vHistory = versionableNode.getSession().getWorkspace().getVersionManager().getVersionHistory(versionableNode.getPath());
VersionManager vMgr = superuser.getWorkspace().getVersionManager();
vMgr.checkpoint(versionableNode.getPath());
version = vMgr.getBaseVersion(versionableNode.getPath());
if (vHistory.hasVersionLabel(versionLabel)) {
fail("Version label '" + versionLabel + "' is already present in this version history. Label test cannot be performed.");
}
if (vHistory.hasVersionLabel(versionLabel2)) {
fail("Version label '" + versionLabel2 + "' is already present in this version history. Label test cannot be performed.");
}
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class RestoreNodeWithSNSTest method testRestoreWithSNS.
public void testRestoreWithSNS() throws Exception {
int childCount = 5;
// create a test node with /childCount/ children with the same name
Node n = testRootNode.addNode(nodeName1);
n.addMixin(mixVersionable);
for (int i = 0; i < childCount; i++) {
Node child = n.addNode(nodeName2);
child.setProperty("name", nodeName2 + i);
}
testRootNode.getSession().save();
// check the number of children
assertEquals(childCount, n.getNodes().getSize());
VersionManager vm = testRootNode.getSession().getWorkspace().getVersionManager();
vm.checkin(n.getPath());
// modify one child
vm.checkout(n.getPath());
n.getNode(nodeName2).setProperty("name", "modified");
testRootNode.getSession().save();
// check the number of children again
assertEquals(childCount, n.getNodes().getSize());
// restore base versiob
Version baseVersion = vm.getBaseVersion(n.getPath());
vm.restore(baseVersion, true);
n.getSession().refresh(false);
// check the number of children again
assertEquals(childCount, n.getNodes().getSize());
}
use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class WorkspaceRestoreTest method testWorkspaceRestoreOnCheckedOutNodeJcr2.
/**
* Test if workspace-restoring a node works on checked-out node.
*/
public void testWorkspaceRestoreOnCheckedOutNodeJcr2() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
if (!versionManager.isCheckedOut(path)) {
versionManager.checkout(path);
}
superuser.getWorkspace().getVersionManager().restore(new Version[] { version }, true);
}
Aggregations