I'm new to Arquillian,
but I managed finally to write tests succesfully that work with a embedded glassfish 3.1 and test my JPA-Methods from entities (namedQueries so far) with its derby-Database. CDI of Entitymanager and UserTranscation works fine.
@PersistenceContext
private EntityManager em;
@Inject
UserTransaction utx;
Now I wanted to test my namedQueries with my real server: Glassfish 4.1 and Arquillian 1.1.11.Final.
My Project declared BeanDiscoveryMode as All and I it works to the point, that I want inject a EntityManager.
I get following Exception:
java.lang.RuntimeException: Could not inject members
at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:135)
at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.enrich(CDIInjectionEnricher.java:78)
at org.jboss.arquillian.test.impl.TestInstanceEnricher.enrich(TestInstanceEnricher.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
My simple Test looks like this:
@RunWith(Arquillian.class)
public class MitarbeiterTestRemote {
@PersistenceContext
private EntityManager em;
@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addClasses(Mitarbeiter.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Test
public void testMethode() {
Assert.assertTrue(1 < 5);
}
}
Did I miss to change something important, so that my injection can work? Do you need other information to help me with this problem?
Thanks so far.
Comments