users@glassfish.java.net

Re: Deisgn pattern question, seed Data initialization ?

From: Dominik Dorn <dominik.dorn_at_gmail.com>
Date: Thu, 24 Dec 2009 19:11:26 +0100

Do you want to insert data for production of for test use?

I successfully used hibernates import.sql to create database with initial
data for test purposes.

For production use, I always prepared the db to the level it should be in
the
beginning and then exported this state. A new installation would then import
this state.

When testing against the database, please keep in mind that it is best
practice
to make your tests transactional, meaning a transaction.rollback in the
teardown
or your tests, effectively resetting the db to a known state. This also
prevents you
from writing tests that depend on each other (e.g. test1 inserts data, test2
reads
the data test1 inserted etc... very bad practice)

I always used springs AbstractTransactionalJunit4SpringContextTests for
this.. don't
know how to do this best in javaEE6 though.

Maybe some of the experts share their knowledge? How do you do TDD with
JavaEE6?


On Thu, Dec 24, 2009 at 6:34 PM, <glassfish_at_javadesktop.org> wrote:

> Nevermind, I have found an excellent way to achieve that.
>
> I will use DBUnit to extract data from xml file and run a junit test that
> will insert those data
> [Message sent by forum member 'anajjar' (a.najjar_at_me.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=377399
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>


-- 
Dominik Dorn
http://dominikdorn.com