I'm trying to implement some IT-Testing. I'm using Arquillian. I can build a war with Shrinkwrap and everything seems to work like excepted.
My Problem, the Entity Classes are not getting enhanced from Hibernate and therefore the test fails.
My code:
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addPackages(true, "x.y.z.acme")
Error:
Caused by: org.jboss.arquillian.test.spi.ArquillianProxyException:
org.apache.openjpa.persistence.ArgumentException : The type "class
x.y.z.acme.persistence.entity.AnEntity" has not been enhanced.
[Proxied because : Original exception caused: class
java.lang.ClassNotFoundException:
org.apache.openjpa.persistence.ArgumentException]
How could i resolve this issue? Preferable without using a second project for IT-Testing
I have found the solution myself. I forgotten to add the persistence.xml to the WebArchive. My @Deployment
method looks now like this:
@Deployment
public static WebArchive createJavaTestArchive() throws IOException {
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addPackages(
true,
"x.y.z.acme",
"javax.persistence" // Tomee does not contain JPA2.1
)
;
File beansXml = new File("src/main/resources/META-INF/beans.xml");
war.addAsManifestResource(beansXml, "beans.xml");
File persistenceXm = new File("src/test/resources/test-persistence.xml");
war.addAsResource(persistenceXm, "META-INF/persistence.xml");
war.addAsResource(new File("src/main/resources/import.sql"));
File[] libs = Maven.resolver().loadPomFromFile("pom.xml")
.importRuntimeDependencies().resolve().withTransitivity().asFile();
war.addAsLibraries(libs);
System.out.print(war.toString(true));
return war;
}