John Rumpel
John Rumpel

Reputation: 4615

JUnit/Arquillian: Run managed Wildfly 8.1 container

I'm trying to bring a simple test case to run:

Is there anywhere a clean set of instructions how to run Java EE integration tests on managed Wildfly 8 containers?

Now where do I have to reference the Wildfly folder?

1) I could do it within my test/resource/arquillian.xml via:

<container qualifier="arquillian-wildfly8-managed" default="true">
    <configuration>
        <property name="jbossHome">target/wildfly-8.1.0.Final</property>
        <property name="modulePath">target/wildfly-8.1.0.Final/modules</property>
    </configuration>
</container>

2) Another way would be to configure the surefire-plugin's system properties within the pom file:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-surefire-plugin</artifactId>
   <version>2.17</version>
   <configuration>
    <property>
        <name>jboss.home</name>
        <value>${project.basedir}/target/wildfly-8.1.0.Final</value>
    </property>
    <property>
        <name>module.path</name>
        <value>${project.basedir}/target/wildfly-8.1.0.Final/modules</value>
    </property>
</systemProperties> </configuration> </plugin>

Now, when I'm trying to run the test, an error is shown:

[ERROR]
/home/me/playground/arquillian-tutorial/src/test/java/org/arquillian/example/ATest.java:[3,19]
error: package javax.inject does not exist

... i.e. the classes are not found.

An excerpt from my pom file:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.17</version>
        </plugin>
    </plugins>
</build>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <version>1.1.5.Final</version>
            <artifactId>arquillian-bom</artifactId>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <!-- <version>1.1.5.Final</version> -->
        <scope>test</scope>
    </dependency>
</dependencies>

    <profile>
        <id>arquillian-wildfly8-managed</id>
        <dependencies>
            <dependency>
                <groupId>org.jboss.spec</groupId>
                <artifactId>jboss-javaee-6.0</artifactId>
                <version>3.0.1.Final</version>
                <type>pom</type>
                <scope>test</scope>
            </dependency>
            <!-- Required by jboss-javaee-6.0:3.0.2.Final (https://issues.jboss.org/browse/JBBUILD-708) -->
            <dependency>
                <groupId>xalan</groupId>
                <artifactId>xalan</artifactId>
                <version>2.7.1</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-arquillian-container-managed</artifactId>
                <version>8.1.0.Final</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <!-- You need the maven dependency plugin to download locally a zip 
                            with the server, unless you provide your own, it will download under the 
                            /target directory -->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.8</version>
                        <executions>
                            <execution>
                                <id>unpack</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wildfly</groupId>
                                            <artifactId>wildfly-dist</artifactId>
                                            <version>8.1.0.Final</version>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                            <outputDirectory>target</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
    </profile>

I am confused. I am unable to find a simple setup to run test cases via Arquillian/Wildfly in a proper way. Do you have any ideas, hints or links?

Upvotes: 5

Views: 6271

Answers (1)

ra2085
ra2085

Reputation: 804

I strongly recommend not to automatically download the .zip file containing the server, but to provide a server instance on your own.

I could do it within my test/resource/arquillian.xml

Yes, that's the way to do it.

Another way would be to configure the surefire-plugin's

No need. Just don't forget to make available the Arquillian.xml file as a test resource in the pom:

<testResources>
     <testResource>
           <directory>path/to/resources</directory>
     </testResource>

Can you post your test case code? I'm interested in having a look to your @Deployment method.

You're missing the EE implemetation dependency on your tests.

<dependency>
                    <groupId>org.jboss.spec</groupId>
                    <artifactId>jboss-javaee-7.0</artifactId>
                    <version>1.0.0.Final</version>
                    <type>pom</type>
                    <scope>provided</scope>
                </dependency>

Upvotes: 0

Related Questions