aspose file tools*
The moose likes Testing and the fly likes Dao integration unit test issue (rollback or temporary database) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Dao integration unit test issue (rollback or temporary database)" Watch "Dao integration unit test issue (rollback or temporary database)" New topic
Author

Dao integration unit test issue (rollback or temporary database)

Haulyn Jason
Ranch Hand

Joined: Jul 24, 2007
Posts: 37
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.


Mama always said, "Life is like a box of chocolates; you never know what you're gonna get. And then you have to get medieval on somebody's buttocks."
http://www.haulynjason.net/
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30309
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Haulyn Jason
Ranch Hand

Joined: Jul 24, 2007
Posts: 37
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

Joined: Jul 24, 2007
Posts: 37
The problem is because my xml is not validated.
DBUnit works very well for my database and project.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dao integration unit test issue (rollback or temporary database)