Search in sources :

Example 1 with JackrabbitQueryResult

use of org.apache.jackrabbit.api.query.JackrabbitQueryResult 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());
}
Also used : NodeIterator(javax.jcr.NodeIterator) QueryResult(javax.jcr.query.QueryResult) JackrabbitQueryResult(org.apache.jackrabbit.api.query.JackrabbitQueryResult) JackrabbitQueryResult(org.apache.jackrabbit.api.query.JackrabbitQueryResult)

Aggregations

NodeIterator (javax.jcr.NodeIterator)1 QueryResult (javax.jcr.query.QueryResult)1 JackrabbitQueryResult (org.apache.jackrabbit.api.query.JackrabbitQueryResult)1