File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes Testing transactions... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Testing transactions..." Watch "Testing transactions..." New topic

Testing transactions...

Eric Nielsen
Ranch Hand

Joined: Dec 14, 2004
Posts: 194
I've been trying to track down some Hibernate/JPA behavior by getting a simple test case. The regular application using OpenEntityMangerInView, and @Transactional annotations on the dao (migrating to a repository pattern).

Most of my tests are true unit tests and hit mocks of the various daos/repositories. I also have a very thin layer of integration tests that test that the dao layer works; so far these test have been very simple and didn't need to worry about transaction semantics.

Now I have a test that is triggering lazy load exceptions, and I'm not sure what's needed in the test environment to get lazy loading to behave in a similar manner as the application.

Here's my test code:

The first getEvents().size() call is where the exception is getting thrown.

Now the dao is very simple (most of it comes from a base class)

The integration tests use a different Spring application context file, but both have identical transaction manager setups.

I beleive the only real difference between my integration test environment and either my full acceptance test environment or production is the OEMIV filter.

How do you establish/deal with transactions in test environments when using Spring annotations to drive transactions in application code?
I agree. Here's the link:
subject: Testing transactions...
It's not a secret anymore!