Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Database DAOs unit test

Developers
2012-09-11
2013-06-06
  • Is there a way to force the database to be recreated? Right now I have setup my test database on H2 database. So I'm running "delete all objects delete files" command to get rid of the database.

    Everything works fine except that the Marauroa part is not reran when I try DatabaseFactory.initializeDatabase because TransactionPool.get() is no longer null (logic check in DatabaseFactory.initializeDatabase).

    To work around this I had to copy and paste the code within DatabaseFactory.initializeDatabase to make it work but that doesn't seem correct. I tried closing the TransactionPool hoping to get it to null but that didn't work either. Am I missing something obvious or is just not possible?

    How are unit tests for DAO's done?

    Since is hard to control the order JUnit execute tests is hard to predict the contents of the database unless it is reset after each test. Any hints on how this is handled?

    Thanks in advance!

     


Anonymous


Cancel   Add attachments