我正在尝试运行一个简单的测试案例:
有没有一个干净的指令集,告诉我如何在管理的Wildfly 8容器上运行Java EE集成测试?
我只想通过
mvn test
在一个新下载的Wildfly容器中运行一个简单的测试案例。文档说对于嵌入式情况,可以使用maven-dependency-plugin的
unpack
目标自动下载并解压Wildfly。我想要将容器设置为管理状态,以确保测试案例拥有一个由Arquillian本身管理的独立JVM。
现在我该在哪里引用Wildfly文件夹?
1) 我可以通过我的test/resource/arquillian.xml
来实现:
<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) 另一种方法是在pom文件中配置surefire-plugin的系统属性:
<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>
现在,当我尝试运行测试时,会显示一个错误:
[ERROR]
/home/me/playground/arquillian-tutorial/src/test/java/org/arquillian/example/ATest.java:[3,19]
error: package javax.inject does not exist
我需要翻译的内容是:“即类找不到。”
我的pom文件摘录如下:
<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>
我很困惑。我找不到一个简单的设置,以适当的方式通过Arquillian / Wildfly运行测试用例。你有任何想法、提示或链接吗?