use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class LimitAndOffsetTest method testOffsetAndLimit.
public void testOffsetAndLimit() throws Exception {
query.setOffset(0);
query.setLimit(1);
QueryResult result = query.execute();
checkResult(result, new Node[] { node1 });
query.setOffset(1);
query.setLimit(1);
result = query.execute();
checkResult(result, new Node[] { node2 });
query.setOffset(1);
query.setLimit(2);
result = query.execute();
checkResult(result, new Node[] { node2, node3 });
query.setOffset(0);
query.setLimit(2);
result = query.execute();
checkResult(result, new Node[] { node1, node2 });
// Added for JCR-1323
query.setOffset(0);
query.setLimit(4);
result = query.execute();
checkResult(result, new Node[] { node1, node2, node3 });
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class LimitAndOffsetTest method testOffsetAndLimitWithGetSize.
public void testOffsetAndLimitWithGetSize() throws Exception {
query.setOffset(1);
QueryResult result = query.execute();
NodeIterator nodes = result.getNodes();
assertEquals(2, nodes.getSize());
if (result instanceof JackrabbitQueryResult) {
assertEquals(3, ((JackrabbitQueryResult) result).getTotalSize());
}
// JCR-2684: offset higher than total result => size == 0
query.setOffset(10);
result = query.execute();
nodes = result.getNodes();
assertFalse(nodes.hasNext());
assertEquals(0, nodes.getSize());
if (result instanceof JackrabbitQueryResult) {
assertEquals(3, ((JackrabbitQueryResult) result).getTotalSize());
}
query.setOffset(1);
query.setLimit(1);
result = query.execute();
nodes = result.getNodes();
assertEquals(1, nodes.getSize());
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class LimitAndOffsetTest method testOffsetAndSkip.
public void testOffsetAndSkip() throws Exception {
query.setOffset(1);
QueryResult result = query.execute();
NodeIterator nodes = result.getNodes();
nodes.skip(1);
assertTrue(node3.isSame(nodes.nextNode()));
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class LimitAndOffsetTest method testOffset.
public void testOffset() throws Exception {
query.setOffset(0);
QueryResult result = query.execute();
checkResult(result, new Node[] { node1, node2, node3 });
query.setOffset(1);
result = query.execute();
checkResult(result, new Node[] { node2, node3 });
query.setOffset(2);
result = query.execute();
checkResult(result, new Node[] { node3 });
}
use of javax.jcr.query.QueryResult in project jackrabbit by apache.
the class LimitAndOffsetTest method testLimit.
public void testLimit() throws Exception {
query.setLimit(1);
QueryResult result = query.execute();
checkResult(result, new Node[] { node1 });
query.setLimit(2);
result = query.execute();
checkResult(result, new Node[] { node1, node2 });
query.setLimit(3);
result = query.execute();
checkResult(result, new Node[] { node1, node2, node3 });
}
Aggregations