use of org.apache.jackrabbit.commons.flat.NodeSequence in project jackrabbit by apache.
the class ItemSequenceTest method testEmptyNodeSequence.
public void testEmptyNodeSequence() throws RepositoryException {
Comparator<String> order = Rank.<String>comparableComparator();
TreeManager treeManager = new BTreeManager(testNode, 5, 10, order, true);
NodeSequence nodes = ItemSequence.createNodeSequence(treeManager, errorHandler);
Iterator<Node> nodeIt = nodes.iterator();
assertTrue(nodeIt.hasNext());
assertTrue(treeManager.isRoot(nodeIt.next()));
assertFalse(nodeIt.hasNext());
checkTreeProperty(testNode, 5, 10, order);
checkOrder(nodes, order);
assertEmpty(nodes);
}
use of org.apache.jackrabbit.commons.flat.NodeSequence in project jackrabbit by apache.
the class ItemSequenceTest method testNodeSequence.
public void testNodeSequence() throws RepositoryException, IOException {
Comparator<String> order = Rank.<String>comparableComparator();
TreeManager treeManager = new BTreeManager(testNode, 5, 10, order, true);
NodeSequence nodes = ItemSequence.createNodeSequence(treeManager, errorHandler);
List<String> words = loadWords();
Collections.shuffle(words);
addAll(nodes, words);
checkTreeProperty(testNode, 5, 10, order);
checkOrder(nodes, order);
Collections.shuffle(words);
checkLookup(nodes, words);
Collections.shuffle(words);
List<String> toRemove = take(words.size() / 5, words);
removeAll(nodes, toRemove);
checkNotFound(nodes, toRemove);
checkLookup(nodes, words);
removeAll(nodes, words);
assertEmpty(nodes);
}
use of org.apache.jackrabbit.commons.flat.NodeSequence in project jackrabbit by apache.
the class ItemSequenceTest method testSingletonNodeSequence.
public void testSingletonNodeSequence() throws RepositoryException {
Comparator<String> order = Rank.<String>comparableComparator();
TreeManager treeManager = new BTreeManager(testNode, 5, 10, order, true);
NodeSequence nodes = ItemSequence.createNodeSequence(treeManager, errorHandler);
nodes.addNode("key", NodeType.NT_UNSTRUCTURED);
assertTrue(nodes.hasItem("key"));
Iterator<Node> nodeIt = nodes.iterator();
assertTrue(nodeIt.hasNext());
assertEquals("key", nodeIt.next().getName());
assertFalse(nodeIt.hasNext());
checkTreeProperty(testNode, 5, 10, order);
checkOrder(nodes, order);
nodes.removeNode("key");
assertEmpty(nodes);
}
Aggregations