You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by "Korver, Aaron" <Aa...@Fiserv.com> on 2005/05/09 21:04:16 UTC

RE: Cactus DBUnit integration (Was:Contacting the container from beginXXX())

Gili,
See the dbunit howto[1] page under the section called "Database setup with
your own TestCase subclass.  Since ServletTestCase is already a TestCase
subclass, I've subclassed it further.  Note that I should probably refactor
it to make a DBUnit decorator class. (favor composition over inheritance)
So, I have a class called "ServiceTestCase" which extends ServletTestCase
and contains some helper methods for dbunit.  Then in the setup() and
teardown() methods of my TestClasses (which extend ServiceTestCase) I follow
the steps shown at the dbunit site.  I hope that this makes sense.

Aaron Korver

[1]http://www.dbunit.org/howto.html



> -----Original Message-----
> From: Gili [mailto:cowwoc@bbs.darktech.org]
> Sent: Monday, May 09, 2005 1:31 PM
> To: Cactus Users List
> Subject: Re: Contacting the container from beginXXX()
> 
> 
> 
> 	DBUnit looks nice but how would you integrate with it 
> Cactus? Each one 
> requires you to extend a different class and Java doesn't do multiple 
> inheritance.
> 
> Gili
> 
> Korver, Aaron wrote:
> > [snip]
> > 
> >>Why don't you simply fill the database with the right values? 
> >>No need for
> >>any hibernate mapping for this! It can be done in several 
> >>ways, with a SQL
> >>script, by saving a database dump and reloading it, etc.
> > 
> > [snip]
> > 
> > May I also suggest using dbunit[1]?  We have been using 
> this successfully in
> > our environment to setup a fixture and restore a DB to a 
> known state.  If
> > you use it with an in-memory DB you can get pretty good 
> performance.  You
> > just want to only do these tests nightly.  Then mock out 
> your DB and run the
> > "logic" tests using mocks.  Remember that developers are 
> lazy, so if your
> > tests take to long to run, then no one will use them.
> > 
> > [1] www.dbunit.org 
> > 
> > Aaron Korver
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> 

RE: Cactus DBUnit integration (Was:Contacting the container from beginXXX())

Posted by Vincent Massol <vm...@pivolis.com>.
Yes and you can also use Cactus' ServletTestSuite if you want:
http://jakarta.apache.org/cactus/writing/howto_testcase.html (read step 2,
option B)

-Vincent

> -----Original Message-----
> From: Korver, Aaron [mailto:Aaron.Korver@Fiserv.com]
> Sent: lundi 9 mai 2005 21:04
> To: 'Cactus Users List'
> Subject: RE: Cactus DBUnit integration (Was:Contacting the container from
> beginXXX())
> 
> Gili,
> See the dbunit howto[1] page under the section called "Database setup with
> your own TestCase subclass.  Since ServletTestCase is already a TestCase
> subclass, I've subclassed it further.  Note that I should probably
> refactor
> it to make a DBUnit decorator class. (favor composition over inheritance)
> So, I have a class called "ServiceTestCase" which extends ServletTestCase
> and contains some helper methods for dbunit.  Then in the setup() and
> teardown() methods of my TestClasses (which extend ServiceTestCase) I
> follow
> the steps shown at the dbunit site.  I hope that this makes sense.
> 
> Aaron Korver
> 
> [1]http://www.dbunit.org/howto.html
> 
> 
> 
> > -----Original Message-----
> > From: Gili [mailto:cowwoc@bbs.darktech.org]
> > Sent: Monday, May 09, 2005 1:31 PM
> > To: Cactus Users List
> > Subject: Re: Contacting the container from beginXXX()
> >
> >
> >
> > 	DBUnit looks nice but how would you integrate with it
> > Cactus? Each one
> > requires you to extend a different class and Java doesn't do multiple
> > inheritance.
> >
> > Gili
> >
> > Korver, Aaron wrote:
> > > [snip]
> > >
> > >>Why don't you simply fill the database with the right values?
> > >>No need for
> > >>any hibernate mapping for this! It can be done in several
> > >>ways, with a SQL
> > >>script, by saving a database dump and reloading it, etc.
> > >
> > > [snip]
> > >
> > > May I also suggest using dbunit[1]?  We have been using
> > this successfully in
> > > our environment to setup a fixture and restore a DB to a
> > known state.  If
> > > you use it with an in-memory DB you can get pretty good
> > performance.  You
> > > just want to only do these tests nightly.  Then mock out
> > your DB and run the
> > > "logic" tests using mocks.  Remember that developers are
> > lazy, so if your
> > > tests take to long to run, then no one will use them.
> > >
> > > [1] www.dbunit.org
> > >
> > > Aaron Korver
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> >