Arquillian testing


Arquillian testing framework helps considerably doing a simple Wildfly/EAP test.

Reasons to be very easy:
1. It is pretty simple to write a test, as any unit test should be and it allows to package the application in one function pretty smothly:

    public static WebArchive createDeployment()
        System.out.println("create Deployment");

        WebArchive archive = ShrinkWrap.create(WebArchive.class, "sample.war")
                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
                .addAsResource("validation.xml", "META-INF/validation.xml");

        System.out.println(archive.toString(true)); File("/tmp/" + archive.getName()), true);

        return archive;

2. Using arquilllian.xml enables to select a certain specific container to be deployed, as little as the lines below to select the container:

  <container qualifier="arquillian-wildfly-managed">
      <property name="chameleonTarget">${}</property>
      <property name="serverConfig">standalone-full.xml</property>

3. Testing is pretty straightforward

    public void Test1() throws Exception
        System.out.println("Calling URI: " + serviceUri.toString()); //to show the url being called

        final String targetUrl = serviceUri.toString() + "hello";"The target URL is: {}", targetUrl);
        ResteasyClient client = new ResteasyClientBuilder().build();
        ResteasyWebTarget target =;
        ValidatedJaxRsInterface validatedJaxRs = target.proxy(ValidateJaxRsInt.class);
  "Validated call responded with: {}", validation.Hello());
        catch (Exception exception)
            log.error("Got an error when calling the validated endpoint: {}", exception.getMessage(),exception);
            if (exception instanceof BadRequestException)
                BadRequestException exp = (BadRequestException) exception;
                log.error("The response was bad request :/ {}", exp.getMessage());
        }"Calling validation.Hello");

4. One can use chameleon or wildfly arquillian straight on the pom to get the container, like below:

        <>jboss eap:${jboss.version}:${container.type}</>

Depending on the EAP version one should use the wildfly arquillian container image instead, see difference below:

<!-- Arquillian Chameleon -->

<!--- wildfly-arquillian-container-managed -->

5. Adding validation becomes almost trivial with the validation.xml file:

   <executable-validation enabled="true">

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 )

Facebook photo

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

Connecting to %s