use of javax.jcr.version.VersionManager in project jackrabbit by apache.
the class MergeSubNodeTest method disable_testMergeNodeBestEffortTrueJcr2.
/**
* VersionManager.merge(): bestEffort is true > (sub)node which could not be merged
* are not affected.<br>
*/
public void disable_testMergeNodeBestEffortTrueJcr2() throws RepositoryException {
// create 2 new nodes with two independent versions
// so merge fails for this node
Node originalNode = testRootNode.getNode(nodeName1);
VersionManager originalVersionManager = originalNode.getSession().getWorkspace().getVersionManager();
String originalPath = originalNode.getPath();
originalVersionManager.checkout(originalPath);
Node subNode = originalNode.getNode(nodeName2);
// will be unchanged after merge
originalVersionManager.checkout(subNode.getPath());
subNode.setProperty(propertyName1, CHANGED_STRING);
// will be updated
originalNode.setProperty(propertyName1, CHANGED_STRING);
superuser.save();
originalVersionManager.checkin(subNode.getPath());
originalVersionManager.checkin(originalPath);
VersionManager versionManager = nodeToMerge.getSession().getWorkspace().getVersionManager();
Node subNodeW2 = nodeToMerge.getNode(nodeName2);
versionManager.checkout(subNodeW2.getPath());
subNodeW2.setProperty(propertyName1, CHANGED_STRING);
superuserW2.save();
versionManager.checkin(subNodeW2.getPath());
versionManager.checkout(nodeToMerge.getPath());
// merge, besteffort set to true
versionManager.merge(nodeToMerge.getPath(), workspace.getName(), true);
// sub node should not be touched because merging failed
assertTrue(subNodeW2.getProperty(propertyName1).getString().equals(""));
// test root node should be touched because update
assertFalse(nodeToMerge.getProperty(propertyName1).getString().equals(nodeToMerge.getName()));
}
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());
}
Aggregations