use of javax.jcr.version.Version in project jackrabbit by apache.
the class RestoreTest method testRestoreOrder2Jcr2_4.
/**
* Test the child ordering of restored nodes.
* @throws RepositoryException
*/
public void testRestoreOrder2Jcr2_4() 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(new Version[] { 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.
/**
* 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 RestoreTest method testRestoreOrder2Jcr2_2.
/**
* Test the child ordering of restored nodes.
* @throws RepositoryException
*/
public void testRestoreOrder2Jcr2_2() 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 FrozenNodeTest method testFrozenNodeUUUID.
/**
* @throws RepositoryException
*/
public void testFrozenNodeUUUID() throws RepositoryException {
VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
Version v = versionManager.checkin(path);
Node n = v.getFrozenNode();
String puuid = n.getProperty(jcrUUID).getValue().getString();
String nuuid = n.getIdentifier();
assertEquals("jcr:uuid needs to be equal to the getIdentifier() return value.", nuuid, puuid);
}
use of javax.jcr.version.Version in project jackrabbit by apache.
the class FrozenNodeTest method testFrozenChildNodeNodeType.
/**
* @throws RepositoryException
*/
public void testFrozenChildNodeNodeType() throws RepositoryException {
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 puuid = n.getProperty(jcrPrimaryType).getValue().getString();
String nuuid = n.getPrimaryNodeType().getName();
assertEquals("jcr:primaryType needs to be equal to the getPrimaryNodeType() return value.", nuuid, puuid);
}
Aggregations