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 14:55:42 GMT
On Fri, Oct 2, 2009 at 4:42 PM, Quintin Beukes <quintin@skywalk.co.za>wrote:

> If you really only want to test the JPA entities, and don't mind the
> transactions, why not remove the @Stateless and @EJB completely, and
> just make your test @LocalClient and inject an entity manager?
>

That may be just the ticket.  I wanted to avoid all the boilerplate of
creating and committing transactions.  If I inject an EntityManager into my
LocalClient, is it managed by the container?  Or does it behave in a more
Java SE manner?  Does it start and automatically commit the transaction?

Mainly I'm looking to do whatever is simplest to get the
auto-context-closing behavior of the local InitialContext, because that
wipes out my in-memory H2 database automatically between tests.  I wanted to
combine that behavior with automatic transaction management to eliminate
EntityManager boilerplate operations.  Whatever is the simplest way to do
this involving the least code--I'm all ears.

Best,
Laird

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