Arquillian OpenEJB: deploy and forget archives

Arquillian is great but when testing always on the same app, in a single thread in embedded mode it is a pain to deploy the app for each class.

You can create your own extension as shown by Aslask ( but you need to code it.

If you need the arquillian features that’s probably the best way to go but if you just want to deploy the app OpenEJB has a hack too (probably easier).

This one is mainly intended to deploy an Archive<?> (potentially created by ShrinkWrap) when the container starts. Then you can use it as a client (that’s really great for REST or SOAP testing) and with some server features (basically cdi injection in the context of a single deployment application).

You simply have to define the property¬†openejb.arquillian.predeploy-archives in “properties” attribute of openejb container in arquillian.xml. The value is a comma separated list of qualified name. Then the class is parsed to find all public static methods annotated @Deployment then the archive is deployed.

Here an example:

  <container qualifier="openejb" default="true">
      <property name="properties">
        openejb.arquillian.predeploy-archives = org.superbiz.archives.[SimpleArchive|SimpleArchive2]

The SimpleArchive simply contains the method:

public static WebArchive simple() {
    return ShrinkWrap.create(WebArchive.class, "simple.war")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s