aspose file tools*
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
Author

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: http://aspose.com/file-tools
 
subject: Testing transactions...
 
Similar Threads
Sessions being closed prematurely
Data Access Object Pattern
Transactional DB access without EJB
Spring and Hibernate
too much time to write tests