tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laird Nelson <ljnel...@gmail.com>
Subject Re: Hackety hack: @Test, @LocalClient and @Stateless for simple JPA testing
Date Sat, 03 Oct 2009 16:55:05 GMT
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 <quintin@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 <ljnelson@gmail.com> wrote:
> > On Sat, Oct 3, 2009 at 12:07 PM, Quintin Beukes <quintin@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
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message