use of javax.jcr.version.Version in project jackrabbit by apache.
the class RestoreTest method testRestoreOrder.
/**
* Test the child ordering of restored nodes.
* @throws RepositoryException
*/
@SuppressWarnings("deprecation")
public void testRestoreOrder() 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();
child1.checkin();
child2.checkin();
Version v1 = testRoot.checkin();
// remove node 1
testRoot.checkout();
child1.remove();
testRoot.getSession().save();
testRoot.checkin();
// restore version 1.0
testRoot.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 RestoreTest method testRestoreRemoved.
@SuppressWarnings("deprecation")
public void testRestoreRemoved() throws RepositoryException {
Node parent = versionableNode.getParent();
String oldName = versionableNode.getName();
Version v1 = versionableNode.checkin();
versionableNode.remove();
versionableNode = null;
parent.getSession().save();
parent.restore(v1, oldName, true);
versionableNode = parent.getNode(oldName);
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 testRestoreChild1Jcr2.
public void testRestoreChild1Jcr2() throws RepositoryException {
versionableNode.addNode("child1");
versionableNode.getSession().save();
Version v1 = versionManager.checkin(versionableNode.getPath());
versionManager.checkout(versionableNode.getPath());
Version v2 = versionManager.checkin(versionableNode.getPath());
versionManager.restore(v1, true);
assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
versionManager.restore(version, true);
assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
try {
versionManager.restore(v2, true);
} catch (RepositoryException e) {
fail("Node.restore('1.3') must fail.");
}
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class RestoreTest method testRestoreOrder2Jcr2.
/**
* Test the child ordering of restored nodes.
* @throws RepositoryException
*/
public void testRestoreOrder2Jcr2() 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());
// reoder nodes
versionManager.checkout(testRoot.getPath());
testRoot.orderBefore(nodeName2, nodeName1);
testRoot.getSession().save();
versionManager.checkin(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 RestoreTest method testRestoreOrderJcr2_3.
/**
* Test the child ordering of restored nodes.
* @throws RepositoryException
*/
public void testRestoreOrderJcr2_3() 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(testRoot.getPath(), v1.getName(), 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);
}
Aggregations