Integration Testing w/ Maven, Arquillian, & JBoss EAP 5

Arquillian targets JBoss Application Server (5 / 5.1 / 6). However, it does not target JBoss Enterprise Application Platform 5.

That being said, Arquillian can be configured to target JBoss EAP 5 using both JBoss AS 5.1 and JBoss AS 6.0 dependencies.

Prerequisites:

  • The Arquillian tests will be JUnit tests.
  • The Arquillian test class names will be suffixed with ‘IT’.
  • The Arquillian tests will be executed against a JBoss EAP 5.1.2 server that is running and reachable via localhost.

Step 1 – Profile Service Configuration

Update the JBoss EAP 5 profile service (deploy/profileservice-jboss-beans.xml) to disable authentication. If authentication is enabled, Arquillian will be unable to deploy the archive.

Comment out the following beans nested within the ProfileServiceProxyFactory bean as shown.

<!-- comment this list to disable auth checks for the profileservice -->
<!--
   <bean>
      <constructor>
         <parameter>
            <value-factory bean="JNDIBasedSecurityManagement"
               method="getAuthenticationManager" parameter="jmx-console"/>
         </parameter>
      </constructor>
   </bean>
   <bean>
      <constructor>
         <parameter>
            <value-factory bean="JNDIBasedSecurityManagement"
               method="getAuthenticationManager" parameter="jmx-console"/>
         </parameter>
         <parameter>
            <value-factory bean="JNDIBasedSecurityManagement"
               method="getAuthenticationManager" parameter="jmx-console"/>
         </parameter>
      </constructor>
   </bean>
-->

Step 2 – JUnit Dependency

Add the JUnit dependency to either the parent POM or the project POM.

<dependencies>
   <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.1</version>
      <scope>test</scope>
   </dependency>
</dependencies>

Step 3 – Surefire Plugin Configuration 1/2

The Surefire plugin should be configured in either the parent or the project POM to exclude integration tests from the test phase.

<build>
   <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <version>2.11</version>
         <configuration>
            <excludes>
               <exclude>**/*IT.java</exclude>
            </excludes>
         </configuration>
      </plugin>
   </plugins>
</build>

Step 4 – Arquillian / JUnit Dependency

Add the Arquillian JUnit dependency to the project POM.

<dependencies>
   <dependency>
      <groupId>org.jboss.arquillian</groupId>
      <artifactId>arquillian-junit</artifactId>
      <version>1.0.0.Alpha5</version>
      <scope>test</scope>
   </dependency>
</dependencies>

Step 5 – Profile

Create a profile in the project POM for executing the integration tests.

<profiles>
   <profile>
      <id>localhost-remote</id>
   </profile>
</profiles>

Step 6 – Surefire Configuration 2/2

Configure the Surefire plugin in the profile to execute the integration tests.

<profiles>
   <profile>
      <id>localhost-remote</id>
      <build>
         <plugins>
            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-surefire-plugin</artifactId>
               <version>2.11</version>
               <executions>
                  <execution>
                     <id>integration-test</id>
                     <phase>integration-test</phase>
                     <goals>
                        <goal>test</goal>
                     </goals>
                     <configuration>
                        <excludes>
                           <exclude>none</exclude>
                        </excludes>
                        <includes>
                           <include>**/*IT.java</include>
                        </includes>
                     </configuration>
                  </execution>
               </executions>
            </plugin>
         </plugins>
      </build>
   </profile>
</profiles>

Step 7 – Arquillian Dependencies

Add the necessary Arquillian dependencies for executing the tests inside/against a JBoss EAP 5.1.2 server that has been started and is available via localhost.

Note that Arquillian with JBoss EAP 5 requires the JBoss AS 5.1 client, but the JBoss AS 6.0 profile service client.

<profiles>
   <profile>
      <id>localhost-remote</id>
      <dependencies>
         <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-jbossas-remote-5.1</artifactId>
            <version>1.0.0.Alpha5</version>
            </dependency>
         <dependency>
            <groupId>org.jboss.jbossas</groupId>
            <artifactId>jboss-as-client</artifactId>
            <version>5.1.0.GA</version>
            <type>pom</type>
         </dependency>
         <dependency>
            <groupId>org.jboss.jbossas</groupId>
            <artifactId>jboss-as-profileservice-client</artifactId>
            <version>6.0.0.Final</version>
            <type>pom</type>
         </dependency>
      </dependencies>
      <build>
         <plugins>
            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-surefire-plugin</artifactId>
               <version>2.11</version>
               <executions>
                  <execution>
                     <id>integration-test</id>
                     <phase>integration-test</phase>
                     <goals>
                        <goal>test</goal>
                     </goals>
                     <configuration>
                        <excludes>
                           <exclude>none</exclude>
                        </excludes>
                        <includes>
                           <include>**/*IT.java</include>
                        </includes>
                     </configuration>
                  </execution>
               </executions>
            </plugin>
         </plugins>
      </build>
   </profile>
</profiles>

Update: The parent of the jboss-as-client dependency (jboss-as-parent) includes repository configuration for the old JBoss Maven repository (http://repository.jboss.org/maven2). Therefore, a mirror has to be configured in the Maven settings.xml file so that this repository is replaced with the new JBoss Nexus (Deprecated) repository (https://repository.jboss.org/nexus).

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
   <mirrors>
      <mirror>
         <mirrorOfLayouts/>
         <id>jboss-deprecated</id>
         <name>JBoss Deprecated Repository</name>
         <url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
         <mirrorOf>repository.jboss.org</mirrorOf>
      </mirror>
   </mirrors>
</settings>

</post>

JBoss EAP 5 & Maven

  • JBoss Maven Java EE 5 Dependencies (link)
  • Configuring the Maven Ear Plugin for JBoss EAP 5 (link)
  • Integration Testing w/ Maven, Cargo, & JBoss EAP 5 (link)
  • Integration Testing w/ Maven, Arquillian, & JBoss EAP 5
  • JBoss EAP 5 Multi-Module Maven Project Structures (link)
  • JBoss Trading – Multi Module JBoss EAP 5 Project (link)
, , ,

About Shane K Johnson

Technical Marketing Manager, Red Hat Inc.

View all posts by Shane K Johnson

5 Comments on “Integration Testing w/ Maven, Arquillian, & JBoss EAP 5”

  1. Mathew Bukowicz Says:

    Nice post, but I wished you had put some code showing Arquillian in action.

    Reply

  2. Aslak Knutsen (@aslakknutsen) Says:

    Nice post!

    I created a example setup with some updated version/setup and secured server support if you’re interested:

    The Showcase is a good place to see Arquillian in action; cdi, ejb, jms, jaxrs, jpa, ui, servlet, jaxws, jsf.

    https://github.com/arquillian/arquillian-showcase

    Reply

    • Shane K Johnson Says:

      Outstanding!

      I just reverted my changes to the profileservice-jboss-beans.xml file, uncommented out the admin user in the jmx-console-users.properties file, and updated my project per your setup.

      It worked like a charm.

      Reply

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Follow

Get every new post delivered to your Inbox.

Join 115 other followers

%d bloggers like this: