ojbIter.releaseDbResources();
}
public void testPagingPosition()
{
OJBIterator ojbIter;
Criteria crit;
QueryByCriteria query;
Collection fullColl, pagedColl;
InterfaceArticle article;
// All Articles index in range
crit = new Criteria();
query = QueryFactory.newQuery(Article.class, crit);
query.addOrderByAscending("articleId");
fullColl = broker.getCollectionByQuery(query);
// limited query
query.setStartAtIndex(10);
query.setEndAtIndex(14);
pagedColl = broker.getCollectionByQuery(query);
ojbIter = (OJBIterator)broker.getIteratorByQuery(query);
assertEquals("collection- and iterator-size must match", pagedColl.size(), ojbIter.size());
assertEquals("index 10 - 14 expecting 5 rows", 5,ojbIter.size());
ojbIter.absolute(2);
article = (InterfaceArticle)ojbIter.next();
assertEquals("Article id=12", article.getArticleId(), 12);
ojbIter.relative(-1);
article = (InterfaceArticle)ojbIter.next();
assertEquals("Article id=12", article.getArticleId(), 12);
ojbIter.relative(-1);
article = (InterfaceArticle)ojbIter.next();
assertEquals("Article id=12", article.getArticleId(), 12);
// last
ojbIter.absolute(12);
article = (InterfaceArticle)ojbIter.next();
assertEquals("Article id=15", article.getArticleId(), 15);
// first
ojbIter.absolute(-12);
article = (InterfaceArticle)ojbIter.next();
assertEquals("Article id=10", article.getArticleId(), 10);
ojbIter.releaseDbResources();
}