use of javax.jcr.RangeIterator in project jackrabbit by apache.
the class FilteredRangeIteratorTest method testSkip.
public void testSkip() {
RangeIterator iterator = new FilteredRangeIterator(LIST.iterator());
assertEquals(3, iterator.getSize());
assertEquals(0, iterator.getPosition());
assertTrue(iterator.hasNext());
assertEquals("x", iterator.next());
iterator.skip(1);
assertEquals(2, iterator.getPosition());
assertTrue(iterator.hasNext());
assertEquals("z", iterator.next());
assertEquals(3, iterator.getPosition());
assertFalse(iterator.hasNext());
}
use of javax.jcr.RangeIterator in project jackrabbit by apache.
the class FilteredRangeIteratorTest method testMatchNone.
public void testMatchNone() {
RangeIterator iterator = new FilteredRangeIterator(LIST.iterator(), Predicate.FALSE);
assertEquals(0, iterator.getSize());
assertEquals(0, iterator.getPosition());
assertFalse(iterator.hasNext());
}
use of javax.jcr.RangeIterator in project jackrabbit by apache.
the class LazyItemIteratorTest method testSizeOfEmptyIteratorIsZero.
public void testSizeOfEmptyIteratorIsZero() throws RepositoryException {
int i = 0;
String nameHint = "noExisting";
String name = nameHint;
while (testRootNode.hasProperty(name)) {
name = name + i;
i++;
}
// retrieve PropertyIterator for a name that does not exist as Property
RangeIterator it = testRootNode.getProperties(name);
assertTrue(it.getSize() == 0);
name = nameHint;
while (testRootNode.hasNode(name)) {
name = name + i;
i++;
}
// retrieve NodeIterator for a name that does not exist as Node
it = testRootNode.getNodes(name);
assertTrue(it.getSize() == 0);
}
use of javax.jcr.RangeIterator in project jackrabbit by apache.
the class LazyItemIteratorTest method testSizeGreaterMinusOne.
public void testSizeGreaterMinusOne() throws RepositoryException {
RangeIterator it = testRootNode.getProperties();
// a node always has at least a single property
assertTrue(it.getSize() > 0);
if (testRootNode.hasNodes()) {
it = testRootNode.getNodes();
// a node always has at least a single property
assertTrue(it.getSize() > 0);
}
}
use of javax.jcr.RangeIterator in project sling by apache.
the class MockNode method getProperties.
@Override
public PropertyIterator getProperties(final String namePattern) throws RepositoryException {
final Pattern pattern = Pattern.compile(namePattern);
RangeIterator items = getMockedSession().listChildren(getPath(), new ItemFilter() {
@Override
public boolean accept(final ItemData item) throws RepositoryException {
return item.isProperty() && pattern.matcher(item.getName()).matches();
}
});
return new PropertyIteratorAdapter(items, items.getSize());
}
Aggregations