Hi all.
I'm building an application using OpenJPA 2.0.0, Jersey 1.3, and JUnit 4.8.1.
I've set it up so I have two different persistence units defined in my persistence.xml: "default" and "unittest." Default is set up to connect to an Oracle instance, while unittest is set up to connect to a local H2DB embedded database file. I do this so that I always start my unit tests with a clean database which has certain known data in it, which can be overwritten between each run of the unit tests.
The problem is that now I want to use the Jersey Testing Framework to test my actual webservices, rather than just the lower layers of the program. My root resource classes don't load the unittest persistence unit, they always load the default.
So what I probably need to do is to inject into the root resource classes which persistence unit should be used to instantiate the EntityManager, and then have some way to inject unittest when I'm running my tests but inject default otherwise. But I can't think of any good way to do that.
I'm brand new to Java EE development, which might be obvious.
Any help?