public class DbIdGeneratorTest extends DbHsqldbTestCase {
@Test
public void testIdGen() throws Exception {
DbSession session = new DbSession(cp);
ThreadDbSessionHolder.set(session);
AppDao appDao = new AppDao();
appDao.setKeysGeneratedByDatabase(false);
appDao.dbIdGenerator = new DbIdGenerator();
Girl girl = new Girl();
girl.name = "One";
girl.speciality = "Code";
appDao.store(girl);
assertEquals(1, girl.getId().longValue());
girl = new Girl();
girl.name = "Two";
girl.speciality = "Dddd";
appDao.store(girl);
assertEquals(2, girl.getId().longValue());
appDao.dbIdGenerator.reset();
girl = new Girl();
girl.name = "Three";
girl.speciality = "Ssss";
appDao.store(girl);
assertEquals(3, girl.getId().longValue());
assertEquals(3, appDao.count(Girl.class));
assertNotNull(appDao.findById(Girl.class, 1));
assertNotNull(appDao.findById(Girl.class, 2));
assertNotNull(appDao.findById(Girl.class, 3));
session.closeSession();
ThreadDbSessionHolder.remove();
}