tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Quintin Beukes <>
Subject Re: Hackety hack: @Test, @LocalClient and @Stateless for simple JPA testing
Date Sat, 03 Oct 2009 16:47:33 GMT

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

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 <> wrote:
> On Sat, Oct 3, 2009 at 12:07 PM, Quintin Beukes <>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

View raw message