use of javax.jcr.Node in project jackrabbit by apache.
the class RestoreTest method testRestoreOrder2Jcr2_3.
/**
* Test the child ordering of restored nodes.
* @throws RepositoryException
*/
public void testRestoreOrder2Jcr2_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());
// 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.Node in project jackrabbit by apache.
the class RestoreTest method testRestoreWithUUIDConflictJcr2_2.
/**
* Tests if restoring the <code>Version</code> of an existing node throws an
* <code>ItemExistsException</code> if removeExisting is set to FALSE.
*/
public void testRestoreWithUUIDConflictJcr2_2() throws RepositoryException, NotExecutableException {
try {
Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
// Verify that nodes used for the test have proper opv behaviour
NodeDefinition nd = naa.getDefinition();
if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
}
Version v = versionManager.checkin(versionableNode.getPath());
versionManager.checkout(versionableNode.getPath());
superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
superuser.save();
versionManager.restore(v, false);
fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
} catch (ItemExistsException e) {
// success
}
}
use of javax.jcr.Node 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.Node in project jackrabbit by apache.
the class MergeSubNodeTest method disable_testMergeNodeFromUpdatedSourceWorkspace.
/**
* Node.merge(): versionable subNode N checked-in: If V' is a successor (to
* any degree) of V, then the merge result for N is update<br> modify a node
* on the workspace1 and then merge the one in workspace2 with the one in
* workspace1 precondition is that the node in workspace2 is checked in
*/
@SuppressWarnings("deprecation")
public void disable_testMergeNodeFromUpdatedSourceWorkspace() throws RepositoryException {
Node originalNode = testRootNode.getNode(nodeName1);
// update nodeName1 on workspace1
originalNode.checkout();
originalNode.checkin();
testRootNode.getSession().save();
// "merge" the clonedNode with the newNode from the default workspace
// besteffort set to false to stop at the first failure
nodeToMerge.merge(workspace.getName(), false);
final String originalBaseVersionUUID = originalNode.getBaseVersion().getUUID();
final String clonedBaseVersionUUID = nodeToMerge.getBaseVersion().getUUID();
assertTrue("clonedNode has different version UUID than expected, it should be updated with the newNode version UUID", originalBaseVersionUUID.equals(clonedBaseVersionUUID));
}
use of javax.jcr.Node 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);
}
Aggregations