db.close();
}
public void testOQL() throws PersistenceException {
OQLQuery oql;
QueryResults results;
Database db = _category.getDatabase();
db.begin();
oql = db.getOQLQuery("SELECT a FROM "
+ SelfRelationFolder.class.getName() + " a");
results = oql.execute();
assertTrue(results.hasMore());
int counter = 0;
SelfRelationFolder f;
f = (SelfRelationFolder) results.next();
assertNotNull(f);
assertEquals(1, f.getId().intValue());
assertEquals("parent", f.getName());
counter++;
f = (SelfRelationFolder) results.next();
assertNotNull(f);
assertEquals(2, f.getId().intValue());
assertEquals("first child", f.getName());
counter++;
f = (SelfRelationFolder) results.next();
assertNotNull(f);
assertEquals(3, f.getId().intValue());
assertEquals("second child", f.getName());
counter++;
f = (SelfRelationFolder) results.next();
assertNotNull(f);
assertEquals(5, f.getId().intValue());
assertEquals("Test Folder", f.getName());
counter++;
f = (SelfRelationFolder) results.next();
assertNotNull(f);
assertEquals(6, f.getId().intValue());
assertEquals("Test Child", f.getName());
counter++;
f = (SelfRelationFolder) results.next();
assertNotNull(f);
assertEquals(7, f.getId().intValue());
assertEquals("Test Grandchild", f.getName());
counter++;
f = (SelfRelationFolder) results.next();
assertNotNull(f);
assertEquals(8, f.getId().intValue());
assertEquals("Test Greatgrandchild", f.getName());
counter++;
oql.close();
db.commit();
db.close();
assertEquals("At least 7 folders should have been returned", 7, counter);