@Test
public void shouldFailToSkipBeyondSize() throws RepositoryException {

    String sql = "SELECT * FROM [nt:base] WHERE [car:year] < 2009";
    Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    QueryResult result = query.execute();
    final int count = 13;
    validateQuery().rowCount(count).warnings(1).hasColumns(allColumnNames("nt:base")).validate(query, result);
    query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    result = query.execute();
    NodeIterator iter = result.getNodes();
    assertTrue(iter.hasNext());
    assertThat(iter.next(), is(notNullValue()));
    iter.skip(count - 2);
    assertTrue(iter.hasNext());
    assertThat(iter.next(), is(notNullValue()));
    // we're at the next one ...
    assertThat(iter.hasNext(), is(false));
    try {
        iter.skip(3);
        fail("Expected NoSuchElementException if skipping past end");
    } catch (NoSuchElementException e) {
        // expected
    }
    // Do it again and skip past the end ...
    query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    result = query.execute();
    iter = result.getNodes();
    try {
        iter.skip(count + 1);
        fail("Expected NoSuchElementException if skipping past end");
    } catch (NoSuchElementException e) {
        // expected
    }
}