JavaEE: Arquillian Tests support Multi-WAR-EARs

Before version 1.0.2 Arquillian did not support EAR deployments which contained multiple WAR files. The issue was the selection of the WAR into which the arquillian artifacts are to be placed for testing. The trick until then was to remove all WAR files not needed and to leave only one WAR within the EAR.

Starting from version 1.0.2 Arquillian does support Multi-WAR-EAR-Deployments as described in http://arquillian.org/blog/2012/07/25/arquillian-core-1-0-2-Final.

If you have an EAR which is used via

EnterpriseArchive ear = ShrinkWrap.createFromZipFile(EnterpriseArchive.class, earFile);

you can select a WAR with the following lines:

    WebArchive testableWar = ear.getAsType(WebArchive.class,
        "war_under_test.war");
    ear.delete("war_under_test.war");
    ear.addAsModule(Testable.archiveToTest(testableWar));

That’s it. After this selection Arquillian stops complaining about multiple WAR files within the EAR and the selected WAR is enriched and tested.

Leave a Reply