use of javax.jcr.version.Version in project jackrabbit by apache.
the class RestoreTest method testRestoreRemovedJcr2.
public void testRestoreRemovedJcr2() throws RepositoryException {
String path = versionableNode.getPath();
Version v1 = versionManager.checkin(path);
versionableNode.remove();
versionableNode = null;
superuser.save();
versionManager.restore(path, v1, true);
versionableNode = superuser.getNode(path);
String value = versionableNode.getProperty(propertyName1).getString();
assertEquals("Restoring a node must set the correct property.", propertyValue2, value);
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class RestoreTest method testRestoreSetsBaseVersionJcr2_2.
/**
* Test if restoring a node sets the jcr:baseVersion property correctly.
*
* @throws javax.jcr.RepositoryException
*/
public void testRestoreSetsBaseVersionJcr2_2() throws RepositoryException {
versionManager.restore(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 testRestoreOrderJcr2.
/**
* Test the child ordering of restored nodes.
* @throws RepositoryException
*/
public void testRestoreOrderJcr2() throws RepositoryException, NotExecutableException {
// create a test-root that has orderable child nodes
Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
ensureMixinType(testRoot, mixVersionable);
versionableNode.getSession().save();
// create children of vNode and checkin
Node child1 = testRoot.addNode(nodeName1);
ensureMixinType(child1, mixVersionable);
Node child2 = testRoot.addNode(nodeName2);
ensureMixinType(child2, mixVersionable);
testRoot.getSession().save();
versionManager.checkin(child1.getPath());
versionManager.checkin(child2.getPath());
Version v1 = versionManager.checkin(testRoot.getPath());
// remove node 1
versionManager.checkout(testRoot.getPath());
child1.remove();
testRoot.getSession().save();
versionManager.checkout(testRoot.getPath());
// restore version 1.0
versionManager.restore(v1, true);
// check order
NodeIterator iter = testRoot.getNodes();
assertTrue(testRoot.getName() + " should have 2 child nodes.", iter.hasNext());
Node n1 = iter.nextNode();
assertTrue(testRoot.getName() + " should have 2 child nodes.", iter.hasNext());
Node n2 = iter.nextNode();
String orderOk = nodeName1 + ", " + nodeName2;
String order = n1.getName() + ", " + n2.getName();
assertEquals("Invalid child node ordering", orderOk, order);
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class OnParentVersionInitializeTest method testRestoreProp.
/**
* Test the restore of a OnParentVersion-INITIALIZE property
*
* @throws javax.jcr.RepositoryException
*/
public void testRestoreProp() throws RepositoryException {
Node propParent = p.getParent();
propParent.checkout();
Version v = propParent.checkin();
propParent.checkout();
p.setValue(newPropValue);
p.save();
propParent.restore(v, false);
assertEquals("On restore of a OnParentVersion-INITIALIZE property P, the current value of P must be left unchanged.", p.getString(), newPropValue);
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class VersionLabelTest method testGetVersionLabelsForInvalidVersion.
/**
* Test if versionHistory.getVersionLabels(Version) throws a VersionException if the
* specified version is not in this version history.
*/
public void testGetVersionLabelsForInvalidVersion() throws Exception {
// build a second versionable node below the testroot to get it's version.
Node versionableNode2 = createVersionableNode(testRootNode, nodeName2, versionableNodeType);
Version invalidV = versionableNode2.checkin();
try {
vHistory.getVersionLabels(invalidV);
fail("VersionHistory.getVersionLabels(Version) must throw a VersionException if the specified version is not in this version history");
} catch (VersionException ve) {
// success
}
}
Aggregations