public void testBeginRangeSubs() {
OpenJPAEntityManager em =
(OpenJPAEntityManager) currentEntityManager();
startTx(em);
OpenJPAQuery q = em.createQuery(
"SELECT r FROM RuntimeTest1 r ORDER BY r.stringField ASC");
for (int i = 0; i < 7; i++) {
q.setFirstResult(i);
Long l = new Long(Long.MAX_VALUE);
q.setMaxResults(100000);
List res = (List) q.getResultList();
assertEquals(6 - i, res.size());
int idx = 0;
// try both random acess and iteration
for (int j = 0; j < res.size(); j++)
assertEquals("TestQueryResults" + (j + 1 + i),
((RuntimeTest1) res.get(j)).getStringField());
for (Iterator itr = res.iterator(); itr.hasNext(); idx++)
assertEquals("TestQueryResults" + (idx + 1 + i),
((RuntimeTest1) itr.next()).getStringField());
}
q.closeAll();
endTx(em);
endEm(em);
}