• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dao integration unit test issue (rollback or temporary database)

 
Haulyn Jason
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all
I meet a issue on integration unit test on Dao layer.

Before this project, we use Spring as IoC and Transaction manager, so in our Dao layer's integration unit test, the database could auto-rollback. Spring support a super class for inherit. But this time we migrate to Guice, no features like Spring's solution.

I think, we can use hsql instead of mysql for testing, so we do not need to rollback to prevent dirty data. But I need more suggestions.

Does anyone have better suggestions ? Thanks very much.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34669
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jia,
A temporary database (as your are suggesting) or rolling back the database to a known state (via a tool like dbunit) are the most common solutions.
 
Haulyn Jason
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you,Jeanne
I tried DBUnit, it works well for most of times.
HSQL does not work for me, because my java application persistence layer is not based on Hibernate or JPA, so my schema sql script is created for MySQL5.

DBUnit works well but I am confused with a bit.

I use UUID as Key in MySQL 5 InnoDB, and the data type is not varchar(36), it's varbinary(36). DBUnit doesn't work for this type for dataset(xml).

I am trying to solve the problem.
 
Haulyn Jason
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is because my xml is not validated.
DBUnit works very well for my database and project.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic