I’m trying junit test with CDI/Weld and JEEUnit. I get this message on startup:
189 [main] INFO org.jboss.weld.Bootstrap - WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
Later on, the Entitymanager fails when I call em.flush() because they expect a transaction to be active. Is there a lightweight transaction implementation I can use for JUnit testing?
EDIT:
I ended up using GuiceRunner. This is so brilliantly simple…
http://fabiostrozzi.eu/2011/03/27/junit-tests-easy-guice/
You can use openEJB in unit-tests, this should work as expected.
But: As soon as you need a transaction (aka “platform service”) in a test, I would start to call it integration testing – in this case I recommend to use Arquillian for light-weight on-container testing. You will be able to test against your own infrastructure, and use an real-world setup for eg. transactions.
Update: I overlooked that you are using JEEUnit already. That makes my answer pretty obsolete…