Arquillian: Wildfly embedded?

和自甴很熟 提交于 2019-11-29 05:57:59

One should set environment variable JBOSS_HOME to path to jBoss installation. Otherwise, a tag property should be added to arquillian.xml inside a container tag.

<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian
    http://jboss.org/schema/arquillian/arquillian_1_0.xsd">


<container qualifier="jboss" default="true">
    <configuration>
        <property name="jbossHome">/path/to/jboss/as</property>
    </configuration>
</container>

from example application jboss-javaee6-webapp

use systemPropertyVariables

<profile>
<id>INTEGRATION_TESTS</id>
<dependencies>
    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-arquillian-container-embedded</artifactId>
        <version>8.2.0.Final</version>
    </dependency>
    <!-- this is the wildfly emb.container - BUT eventually it is not a fully blown emb.container-->
    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-embedded</artifactId>
        <version>8.2.0.Final</version>
    </dependency>

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <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.2.0.Final</version>
                                <type>zip</type>
                                <overWrite>false</overWrite>
                                <outputDirectory>target</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.0.2.Final</version>
            <executions>
                <execution>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>start</goal>
                    </goals>
                </execution>
                <execution>
                    <id>jdbc</id>
                    <phase>package</phase>
                    <goals>
                        <goal>deploy-artifact</goal>
                    </goals>
                    <configuration>
                        <groupId>com.oracle</groupId>
                        <artifactId>ojdbc6</artifactId>
                        <name>ojdbc6.jar</name>
                    </configuration>
                </execution>
                <execution>
                    <id>datasource</id>
                    <phase>package</phase>
                    <goals>
                        <goal>add-resource</goal>
                    </goals>
                    <configuration>
                        <address>subsystem=datasources,data-source=tests</address>
                        <resources>
                            <resource>
                                <properties>
                                    <connection-url>jdbc:oracle:thin:@***:1521:xe</connection-url>
                                    <jndi-name>java:jboss/datasources/tests</jndi-name>
                                    <enabled>true</enabled>
                                    <enable>true</enable>
                                    <user-name>***</user-name>
                                    <password>***</password>
                                    <driver-name>ojdbc6.jar</driver-name>
                                    <use-ccm>false</use-ccm>
                                </properties>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.17</version>
            <configuration>
                <systemPropertyVariables>
                    <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                    <jboss.home>${project.basedir}/target/wildfly-8.2.0.Final</jboss.home>
                    <module.path>${project.basedir}/target/wildfly-8.2.0.Final/modules</module.path>
                </systemPropertyVariables>
            </configuration>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
                <execution>
                    <id>verify</id>
                    <goals>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>


    </plugins>

</build>

Look at this nice article written by Dan Allen.

To be short: generally do not use an embedded container (glassfish with EclipseLink particularly). Standalone server gives us more accurate test results.

Also I prefer remote adapters due to speed of development (none server startup with every test launch, just start it manually once). If you want the container to start automatically like with embedded, then switch to a managed container.

Hope it helps.

Well, I guess that it works differently w/ Wildfly than with Glassfish:

https://community.jboss.org/thread/236562

:(

Edit: Docker adds another perspective on this issue. I could easily manage the external container using Docker and Maven while still using Arquillian. Did not test it yet, but if someone stumbles upon this...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!