testing web-database apps with maven
It is independent of Maven but DBUnit will provide all you need for database testing and will run as part of junit tests.
See:
http://www.dbunit.org/howto.html
Also useful for this are running the tests intransactions os the database is left in the same state after the test. Spring provides some nice ways of acheiving this. See here:
9.3.5.4 Transaction management - at http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/testing.html#testing-tx
You didn't specify the peristence provider you are using, so I'm not sure if my answer will be of any help. In case you are using Hibernate...
Hibernate3 Maven Plugin has a goal that generates a DDL script from your mappings (it supports JPA annotations, too). Then you can use Maven SQL plugin to execute the DDL script against your database.
This blog post has an example configuration for the Hibernate3 plugin: http://unmaintainable.wordpress.com/2008/04/12/hibernate3-schema-creation/
精彩评论