Basically, all I want to know is your PersistenceProvider class, your data resource InitialContext configuration for the test, and how you create the database in H2.
I got the H2 server running, but went to go shower, so haven't done anything beyond that. Quintin Beukes On Sat, Oct 3, 2009 at 6:55 PM, Laird Nelson <ljnel...@gmail.com> wrote: > I'll try to put it together; it's spread out over a large project base at > the moment. > > Cheers, > Laird > > On Sat, Oct 3, 2009 at 12:47 PM, Quintin Beukes <quin...@skywalk.co.za>wrote: > >> Hey, >> >> This sounds interesting. Actually a nice way to do tests from a clean >> db, a problem I have myself which I circumvented with a modified >> Hibernate. >> >> Can you send me your H2 OpenEJB configuration. I want to set it up and >> see if I can get it going. Will let you know what I come up with - >> even if it means to make a simple junit runner just for this purpose. >> It would be great to have tests run on a clean db everytime. >> >> Quintin Beukes >> >> >> >> On Sat, Oct 3, 2009 at 6:42 PM, Laird Nelson <ljnel...@gmail.com> wrote: >> > On Sat, Oct 3, 2009 at 12:07 PM, Quintin Beukes <quin...@skywalk.co.za >> >wrote: >> > >> >> Yes,it is managed by the container and the context. The initial >> >> context will close with the VM. Afaik it will have the same behaviour >> >> after the test closes as the EJB would. >> > >> > >> > OK; good to know. >> > >> > From you e-mail I figure your focus is on the automatic destruction of >> >> >> > the db. >> > >> > >> > Yes. H2, specifically. >> > >> > I've *never* had luck with the DB being automatically destroyed between >> > tests. I've closed the context, used the magic property (destroyOnClose? >> > don't remember offhand), tried setting up H2 without the DB_CLOSE_DELAY >> > setting, *with* the DB_CLOSE_DELAY setting--nothing. It might have to do >> > with the strange intersection of (a) there being a connection pool and >> (b) >> > H2's being an in-memory database that tries to destroy itself when it >> thinks >> > it's safe to do so. >> > >> > I can verify this because when I have two test methods that each try to >> > persist an object with the same ID--which would succeed in a blank >> > database--my second method fails. >> > >> > To be clear, then, I want my named H2 database to be wiped out and >> > recreated--complete with DDL generation as described by my JPA >> > mappings--before each test method is run. >> > >> > To put it one final way, I want my test code to look like this: >> > X x = new X(); >> > this.em.persist(x); >> > >> > ...i.e. no beginning transactions, no shutting down databases, no mucking >> > about with EntityManagerFactories, etc. etc. etc. Just bare bones >> > simplicity. Frankly OpenEJB need not even be involved, but it seemed >> like >> > an easy black box that would enable most of these kinds of tests. >> > >> > Thanks for getting involved, >> > Laird >> > >> >