Hi there,
I'm trying to migrate my testing framework from JBoss Embedded to OpenEJB
but have run into a bit of a dead end. A lot of my tests are just
exercising entities etc to ensure that they behavour properly (including
constraints etc). We have an abstract EBJTest class which contains a
reference to the EntityManager, extended used by the test classes for each
entity. The EJBTest class initialises the container then gets an
EntityManager instance via JNDI lookup:
entityManager = (EntityManager)
ctx.lookup("java:/EntityManagers/LibertyEM");
transactionManager = (TransactionManager)
ctx.lookup("java:/TransactionManager");
I've seen the page at
http://openejb.apache.org/3.0/injection-of-entitymanager-example.html that
outlines how to objtain an EntityManager via injection. I've been able to
cut over the code for the container initialisation OK, but I can't find any
examples where an EntityManager instance is obtained outside of a EJB.
Is the a way to get an EntityManager reference in a scenerio like this or
would I need to rework all the tests?
Any help greatly appreciated.
Thanks,
Brad