Version 13
    Introduction

    Maven allows us to skip a lot of the manual steps involved in both installing the Application Server and setting up the environment.  These instructions are largely ported from the EmbeddedAS examples (http://anonsvn.jboss.org/repos/jbossas/projects/embedded/examples/trunk/pom.xml).  Here we make all of the AS libraries available upon the Application ClassPath, such that they may be used directly in tests.

     

    Configure Environment
    Set a System Property

    It's useful to set $JBOSS_HOME upfront for use elsewhere in the POM

    <properties>
        <!-- JBOSS_HOME (We'll unpack into here -->
        <JBOSS_HOME>${project.build.directory}/jboss-${version.org.jboss.jbossas}</JBOSS_HOME>
        <!-- The target version of AS to be used -->
        <version.org.jboss.jbossas>6.0.0.20100429-M3</version.org.jboss.jbossas>
    </properties>
    

     

    Dependency Declaration

    For use in tests, we'll pull in all dependencies used by the Application Server in this one declaration.  Maven will transitively fetch everything into the local repository (may take some time on first launch) and set up the ClassPaths accordingly.

    <dependencies>
      <dependency>
        <groupId>org.jboss.jbossas</groupId>
        <artifactId>jboss-as-depchain</artifactId>
        <version>${version.org.jboss.jbossas}</version>
        <type>pom</type>
      </dependency>
      ...
    </dependency>
    
    
    <!--
    We also need to place the AS depchain into 
    the "dependencyManagement" section in import scope
    so that Maven respects the "exclusion" elements
    configured
    -->
    <dependencyManagement>
      <dependencies>
    
        <!-- org.jboss.jbossas -->
        <dependency>
          <groupId>org.jboss.jbossas</groupId>
          <artifactId>jboss-as-depchain</artifactId>
          <version>${version.org.jboss.jbossas}</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
     </dependencies>
    
    </dependencyManagement>

     

    Automatically Download JBossAS

    So that we don't have to manually download and install the Application Server, we can leverage the dependency plugin to do this for us, placing into a transient location which we'll use as our JBOSS_HOME during testing.

    <!-- Get AS and put into "target" -->
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
        <execution>
          <id>unpack</id>
          <phase>pre-integration-test</phase> <!-- So run before testing -->
          <goals>
            <goal>unpack</goal>
          </goals>
          <configuration>
            <artifactItems>
              <artifactItem>
                <groupId>org.jboss.jbossas</groupId>
                <artifactId>jboss-as-distribution</artifactId>
                <version>${version.org.jboss.jbossas}</version>
                <type>zip</type>
                <overWrite>false</overWrite>
                <outputDirectory>${project.build.directory}</outputDirectory>
              </artifactItem>
            </artifactItems>
          </configuration>
        </execution>
      </executions>
    </plugin>
    

     

    Configure Surefire

    Setup the test environment to specify JBOSS_HOME to the location unpacked via the dependency plugin, and pass in some parameters to bump the available permanent generation and heap sizes.

    <plugin>
      <artifactId>maven-surefire-plugin</artifactId>
      <executions>
        <execution>
          <id>integration-test</id>
          <phase>integration-test</phase>
          <goals>
            <goal>test</goal>
          </goals>
          <configuration>
            <additionalClasspathElements>
              <additionalClasspathElement>${JBOSS_HOME}/client/jbossws-native-client.jar</additionalClasspathElement>
            </additionalClasspathElements>
    
            <redirectTestOutputToFile>true</redirectTestOutputToFile>
            <trimStackTrace>false</trimStackTrace>
            <printSummary>true</printSummary>
            <includes>
              <include>**/*IntegrationTest.java</include>
            </includes>
            <forkMode>always</forkMode>
            <!--
              MaxPermSize Required to bump the space for relective
              data like classes, methods, etc. EMB-41, EMB-74. Endorsed
              required for things like WS support (EMB-61)
            -->
            <argLine>-Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Djava.endorsed.dirs=${JBOSS_HOME}/lib/endorsed -Djboss.home=${JBOSS_HOME} -Djboss.boot.server.log.dir=${JBOSS_HOME}</argLine>
          </configuration>
        </execution>
      </executions>
    </plugin>