
Originally Posted by
chenrici
I was wondering, if others also have come across the Requirement to use both the org.dbunit.DatabaseTestCase and die org.springframework.test.AbstractSpringContextTest s Hierarchie.
Specially if there is any commited code around, which helps me with some kind of Mixin Class Composition Approach. If not what would be the a "recommended" approach to achieve this?
Any hints or links appreciated.
Christoph Henrici
If you take a look at DatabaseTestCase class, you will notice that it doesn't do much at all. You can write your own base test class that extends a Spring test class and add dbUnit setup/teardown to it. It's just a couple of lines really, something like:
Code:
protected void onSetUp() throws Exception {
super.onSetUp();
dataSet=...
connection = new DatabaseDataSourceConnection(dataSource);
DatabaseOperation.INSERT.execute(connection, dataSet);
}
protected void onTearDown() throws Exception {
super.onTearDown();
DatabaseOperation.DELETE_ALL.execute(connection, dataSet);
connection.close();
}
or something simmilar.