use of javax.jcr.NodeIterator in project jackrabbit by apache.
the class VersionHistoryTest method testGetAllFrozenNodes.
/**
* Test that {@link VersionHistory#getAllFrozenNodes()} returns an iterator
* containing the frozen nodes of all versions that have been created by
* {@link VersionManager#checkpoint(String)}.
*
* @see javax.jcr.version.VersionHistory#getAllFrozenNodes()
* @since JCR 2.0
*/
public void testGetAllFrozenNodes() throws RepositoryException {
VersionManager vm = versionableNode.getSession().getWorkspace().getVersionManager();
String path = versionableNode.getPath();
int cnt = 2;
for (int i = 0; i < cnt; i++) {
vm.checkpoint(path);
}
Set<String> frozenIds = new HashSet<String>();
for (VersionIterator it = vm.getVersionHistory(path).getAllVersions(); it.hasNext(); ) {
Version v = it.nextVersion();
frozenIds.add(v.getFrozenNode().getIdentifier());
}
Set<String> test = new HashSet<String>();
for (NodeIterator it = vHistory.getAllFrozenNodes(); it.hasNext(); ) {
Node n = it.nextNode();
assertTrue("Node " + n.getPath() + " must be of type frozen node", n.isNodeType("nt:frozenNode"));
test.add(n.getIdentifier());
}
assertEquals("getAllFrozenNodes must return the IDs of all frozen nodes", frozenIds, test);
}
use of javax.jcr.NodeIterator in project jackrabbit by apache.
the class MergeSubNodeTest method disable_testMergeNodeSubNodesMergeTest.
/**
* Node.merge(): For each versionable node N in the subtree rooted at this
* node,<br> a merge test is performed comparing N with its corresponding
* node in workspace, N'.<br>
*/
@SuppressWarnings("deprecation")
public void disable_testMergeNodeSubNodesMergeTest() throws RepositoryException {
//setCheckProperty(nodeToMerge);
nodeToMerge.checkout();
nodeToMerge.merge(workspace.getName(), true);
// check subnodes if they were touched
for (NodeIterator ni = nodeToMerge.getNodes(); ni.hasNext(); ) {
Node n = ni.nextNode();
if (n.getBaseVersion() != null) {
assertTrue(n.getProperty(propertyName1).getString().equals(CHANGED_STRING));
}
}
}
use of javax.jcr.NodeIterator 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.NodeIterator 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.NodeIterator 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