Arkillian test with real EAR built on JBoss 7.1

I want to test a Java EE application with Arquillian. A simple installation works to enable test classes on an Arquillian-managed server to test them.

Now I want to use the EAR file that was created during the build process. Via

@Deployment public static EnterpriseArchive createDeployment() { File earFile = ... EnterpriseArchive archive = ShrinkWrap.createFromZipFile(EnterpriseArchive.class, earFile); return archive; } 

I can put an EAR through Arquillian in JBoss. I see the deployment, and there are no errors during the deployment. Only Arkillian returns with the error that he cannot find a test class, which is obviously good.

Now the question is where to put the test class. I can put the test class in test.war placed in EAR by Arquillian, but I get an ArquillianServletRunner exception that is not found. When I put test classes in JAR files as a module or library, test classes are not detected when installed as a module or injections do not work when they are placed in libraries due to dependency problems.

Where do I need to put test classes on ???

My arquillian.xml:

 <?xml version="1.0" encoding="UTF-8"?> <arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian" xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> <defaultProtocol type="Servlet 3.0" /> <container qualifier="jboss7" default="true"> <configuration> <property name="jbossHome">${cargo.dir}/jboss-as-dist-7.1.1.Final/jboss-as-7.1.1.Final</property> </configuration> </container> <engine> <property name="deploymentExportPath">target/deployments</property> </engine> </arquillian> 
+4
source share
3 answers

You can run the test class on the client side using @Deployment (testable = false), but this has the disadvantage that you cannot use the duration extension (and possibly others) at the moment.

My sample code is:

 @RunWith(Arquillian.class) public class PersonWebServiceIT { private PersonWebService service; @Deployment(testable = false) public static Archive<?> createDeployment() { return ShrinkWrap .create(ZipImporter.class, "test.war") .importFrom( new File("simple-webservice-1.0.0-SNAPSHOT.war")) .as(WebArchive.class); } @Test public void testFindPersons(@ArquillianResource URL deploymentUrl) { .... } } 
0
source

Putting test classes into war inside the ear helped me

 WebArchive war = ear.getAsType(WebArchive.class, "/mywarname.war"); war.addClass(MyTestClass.class); 
0
source

When dealing with an existing EAR, I prefer to separate the WAR, which runs the tests, from the actual tests, which I put in a special JAR along with other test EJBs. I gave an example of how to do this with the necessary application.xml manipulation on a similar issue: fooobar.com/questions/1144558 / ...

0
source

All Articles