目标运行时 WildFly 在 maven 测试后解包
Target runtime WildFly is unpacked after maven tests
我目前正在为 Hibernate 项目 Hibernate Search 构建一个新包,我需要使用 Arquillian 运行 在托管的 WildFly 容器中进行一些单元测试。当我使用命令 mvn clean install
时,出现以下错误:
org.jboss.arquillian.container.spi.ConfigurationException: jbossHome '${project.build.directory}/node1/wildfly-${org.wildfly}' must exist
这个属性配置在./src/test/resources/arquillian.xml
。出现这个异常是"normal"是有原因的:目标文件夹./target/node1/wildfly-10.0.0.Final
不存在。不过maven中应该已经配置了这个路径pom.xml
。所以我尝试 运行 没有测试的 maven 安装:
Mincongs-MBP:gsoc-hsearch mincong$ mvn clean install -DskipTests=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Hibernate Search - JSR352 5.6.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hs-jsr352 ---
[INFO] Deleting /Users/mincong/Documents/GitHub/gsoc-hsearch/target
[INFO]
[INFO] --- dependencypath-maven-plugin:1.1.1:set (set-all) @ hs-jsr352 ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ hs-jsr352 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 16 source files to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/classes
[INFO] /Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/java/org/hibernate/search/jsr352/internal/IndexingContext.java: Some input files use or override a deprecated API.
[INFO] /Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/java/org/hibernate/search/jsr352/internal/IndexingContext.java: Recompile with -Xlint:deprecation for details.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ hs-jsr352 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ hs-jsr352 ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.6:war (default-war) @ hs-jsr352 ---
[INFO] Packaging webapp
[INFO] Assembling webapp [hs-jsr352] in [/Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/webapp]
[INFO] Webapp assembled in [113 msecs]
[INFO] Building war: /Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT.war
[INFO]
[INFO] --- maven-dependency-plugin:2.6:unpack (unpack) @ hs-jsr352 ---
[INFO] Configured Artifact: org.wildfly:wildfly-dist:10.0.0.Final:zip
[INFO] Unpacking /Users/mincong/.m2/repository/org/wildfly/wildfly-dist/10.0.0.Final/wildfly-dist-10.0.0.Final.zip to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/node1 with includes "" and excludes ""
[INFO]
[INFO] --- maven-resources-plugin:2.6:copy-resources (configure-as-node-node1) @ hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/mincong/Documents/GitHub/gsoc-hsearch/src/wildflyConfig
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ hs-jsr352 ---
[INFO] Installing /Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT.war to /Users/mincong/.m2/repository/io/github/mincongh/hs-jsr352/5.6.0-SNAPSHOT/hs-jsr352-5.6.0-SNAPSHOT.war
[INFO] Installing /Users/mincong/Documents/GitHub/gsoc-hsearch/pom.xml to /Users/mincong/.m2/repository/io/github/mincongh/hs-jsr352/5.6.0-SNAPSHOT/hs-jsr352-5.6.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.274 s
[INFO] Finished at: 2016-06-18T16:01:51+02:00
[INFO] Final Memory: 36M/280M
[INFO] ------------------------------------------------------------------------
我注意到:
- 测试位于第 7 步
- WildFly 安装位于第 9 步
因此测试在 运行时间设置之前启动。 因此,我的问题是:
- 如何确保托管 运行time WildFly 10 在测试前解压?
- 对于我的测试class
DeployementTest
,它是预集成/集成测试的一部分吗?
- 如果是,我应该为它使用额外的模块吗?
我在所有这些领域都是新手。如果我混淆了单词或提出了愚蠢的问题,请原谅我...感谢您的帮助!
以下是一些可能有用的相关文件:
./pom.xml
./src/test/resources/arquillian.xml
./src/test/java/org/hibernate/search/jsr352/DeploymentTest.java
./pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.mincongh</groupId>
<artifactId>hs-jsr352</artifactId>
<version>5.6.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Hibernate Search - JSR352</name>
<description>New implementation mass-indexer using JSR 352</description>
<properties>
<org.jboss.arquillian.version>1.1.1.Final</org.jboss.arquillian.version>
<org.wildfly>10.0.0.Final</org.wildfly>
<org.wildfly.arquillian>8.2.1.Final</org.wildfly.arquillian>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<id>perf</id>
<properties>
<org.hibernate.search.enable_performance_tests>true</org.hibernate.search.enable_performance_tests>
</properties>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.11.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.5.3.Final</version>
<!--
<exclusions>
<exclusion>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
</exclusions>
-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.batch</groupId>
<artifactId>javax.batch-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<!-- Not sure the version of EJB, this is provided by GlassFish -->
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>${org.wildfly.arquillian}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.logmanager</groupId>
<artifactId>log4j-jboss-logmanager</artifactId>
</exclusion>
<!-- This exclusion is needed to be able to setup the project in Windows:
it otherwise includes transitive dependency to the JDK JConsole -->
<exclusion>
<artifactId>wildfly-patching</artifactId>
<groupId>org.wildfly</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<!-- Allows to find the absolute path to dependencies -->
<groupId>org.bitstrings.maven.plugins</groupId>
<artifactId>dependencypath-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>set-all</id>
<goals>
<goal>set</goal>
</goals>
<configuration>
<propertySets>
<propertySet>
<includes>
<include>org.jboss.byteman:byteman:jar</include>
</includes>
</propertySet>
</propertySets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<runOrder>alphabetical</runOrder>
<systemPropertyVariables>
<!-- See HSEARCH-1444 -->
<hibernate.service.allow_crawling>false</hibernate.service.allow_crawling>
<com.sun.management.jmxremote>true</com.sun.management.jmxremote>
<org.hibernate.search.enable_performance_tests>${org.hibernate.search.enable_performance_tests}</org.hibernate.search.enable_performance_tests>
</systemPropertyVariables>
<additionalClasspathElements>
<!-- Needed by Byteman to load the agent on demand -->
<additionalClasspathElement>${jdk-toolsjar}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>unpack</id>
<phase>pre-integration-test</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${org.wildfly}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/node1</outputDirectory>
</artifactItem>
<!--
<artifactItem>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-modules</artifactId>
<version>${project.version}</version>
<classifier>wildfly-10-dist</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/node1/wildfly-${org.wildfly}/modules</outputDirectory>
</artifactItem>
-->
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<!-- Copy the AS configuration files so we can use our custom configurations -->
<execution>
<id>configure-as-node-node1</id>
<!-- <phase>pre-integration-test</phase> -->
<phase>integration-test</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/node1/wildfly-${org.wildfly}</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${basedir}/src/wildflyConfig</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
./src/test/resources/arquillian.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate Search, full-text search for your domain model
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<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">
<defaultProtocol type="Servlet 3.0" />
<!-- Uncomment in order to inspect deployments -->
<!--
<engine>
<property name="deploymentExportPath">target/deployments</property>
</engine>
-->
<group qualifier="Grid" default="true">
<container qualifier="container.active-1" mode="suite" default="true">
<configuration>
<property name="jbossHome">${project.build.directory}/node1/wildfly-${org.wildfly}</property>
<!-- Needed for JMS tests -->
<property name="serverConfig">standalone-full-testqueues.xml</property>
<property name="javaVmArguments">-javaagent:${byteman.agent.path}=script:${byteman.script.path} -Xmx512m -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1</property>
<!-- To debug the Arquillian managed application server: -->
<!-- property name="javaVmArguments">-javaagent:${byteman.agent.path}=script:${byteman.script.path} -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y -Xmx512m -Dorg.jboss.remoting-jmx.timeout=300 -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1</property -->
</configuration>
</container>
</group>
</arquillian>
./src/test/java/org/hibernate/search/jsr352/DeploymentTest.java
package org.hibernate.search.jsr352;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
public class DeploymentTest {
@Deployment
public static WebArchive createDeployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addPackages(true, "io.github.mincongh")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsResource("META-INF/batch-jobs/mass-index.xml");
System.out.println(war.toString(true));
return war;
}
@Test
public void startJob() {
// TODO: add tasks here
}
}
也许您混淆了 Maven Surefire 和 Failsafe 插件。
DeploymentTest
以上是单元测试,不是 IT 测试,将由 Surefire 执行。因此,如果您希望使用 maven-dependency-plugin
解压 WildFly,您需要将 unpack
绑定到 <phase>process-test-classes</phase>
等阶段,该阶段将在 Surefire 在 [=14] 之前执行=]相.
Maven 生命周期参考:
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
我目前正在为 Hibernate 项目 Hibernate Search 构建一个新包,我需要使用 Arquillian 运行 在托管的 WildFly 容器中进行一些单元测试。当我使用命令 mvn clean install
时,出现以下错误:
org.jboss.arquillian.container.spi.ConfigurationException: jbossHome '${project.build.directory}/node1/wildfly-${org.wildfly}' must exist
这个属性配置在./src/test/resources/arquillian.xml
。出现这个异常是"normal"是有原因的:目标文件夹./target/node1/wildfly-10.0.0.Final
不存在。不过maven中应该已经配置了这个路径pom.xml
。所以我尝试 运行 没有测试的 maven 安装:
Mincongs-MBP:gsoc-hsearch mincong$ mvn clean install -DskipTests=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Hibernate Search - JSR352 5.6.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hs-jsr352 ---
[INFO] Deleting /Users/mincong/Documents/GitHub/gsoc-hsearch/target
[INFO]
[INFO] --- dependencypath-maven-plugin:1.1.1:set (set-all) @ hs-jsr352 ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ hs-jsr352 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 16 source files to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/classes
[INFO] /Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/java/org/hibernate/search/jsr352/internal/IndexingContext.java: Some input files use or override a deprecated API.
[INFO] /Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/java/org/hibernate/search/jsr352/internal/IndexingContext.java: Recompile with -Xlint:deprecation for details.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ hs-jsr352 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ hs-jsr352 ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.6:war (default-war) @ hs-jsr352 ---
[INFO] Packaging webapp
[INFO] Assembling webapp [hs-jsr352] in [/Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/mincong/Documents/GitHub/gsoc-hsearch/src/main/webapp]
[INFO] Webapp assembled in [113 msecs]
[INFO] Building war: /Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT.war
[INFO]
[INFO] --- maven-dependency-plugin:2.6:unpack (unpack) @ hs-jsr352 ---
[INFO] Configured Artifact: org.wildfly:wildfly-dist:10.0.0.Final:zip
[INFO] Unpacking /Users/mincong/.m2/repository/org/wildfly/wildfly-dist/10.0.0.Final/wildfly-dist-10.0.0.Final.zip to /Users/mincong/Documents/GitHub/gsoc-hsearch/target/node1 with includes "" and excludes ""
[INFO]
[INFO] --- maven-resources-plugin:2.6:copy-resources (configure-as-node-node1) @ hs-jsr352 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/mincong/Documents/GitHub/gsoc-hsearch/src/wildflyConfig
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ hs-jsr352 ---
[INFO] Installing /Users/mincong/Documents/GitHub/gsoc-hsearch/target/hs-jsr352-5.6.0-SNAPSHOT.war to /Users/mincong/.m2/repository/io/github/mincongh/hs-jsr352/5.6.0-SNAPSHOT/hs-jsr352-5.6.0-SNAPSHOT.war
[INFO] Installing /Users/mincong/Documents/GitHub/gsoc-hsearch/pom.xml to /Users/mincong/.m2/repository/io/github/mincongh/hs-jsr352/5.6.0-SNAPSHOT/hs-jsr352-5.6.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.274 s
[INFO] Finished at: 2016-06-18T16:01:51+02:00
[INFO] Final Memory: 36M/280M
[INFO] ------------------------------------------------------------------------
我注意到:
- 测试位于第 7 步
- WildFly 安装位于第 9 步
因此测试在 运行时间设置之前启动。 因此,我的问题是:
- 如何确保托管 运行time WildFly 10 在测试前解压?
- 对于我的测试class
DeployementTest
,它是预集成/集成测试的一部分吗? - 如果是,我应该为它使用额外的模块吗?
我在所有这些领域都是新手。如果我混淆了单词或提出了愚蠢的问题,请原谅我...感谢您的帮助!
以下是一些可能有用的相关文件:
./pom.xml
./src/test/resources/arquillian.xml
./src/test/java/org/hibernate/search/jsr352/DeploymentTest.java
./pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.mincongh</groupId>
<artifactId>hs-jsr352</artifactId>
<version>5.6.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Hibernate Search - JSR352</name>
<description>New implementation mass-indexer using JSR 352</description>
<properties>
<org.jboss.arquillian.version>1.1.1.Final</org.jboss.arquillian.version>
<org.wildfly>10.0.0.Final</org.wildfly>
<org.wildfly.arquillian>8.2.1.Final</org.wildfly.arquillian>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<id>perf</id>
<properties>
<org.hibernate.search.enable_performance_tests>true</org.hibernate.search.enable_performance_tests>
</properties>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.11.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.5.3.Final</version>
<!--
<exclusions>
<exclusion>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
</exclusions>
-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.batch</groupId>
<artifactId>javax.batch-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<!-- Not sure the version of EJB, this is provided by GlassFish -->
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>${org.wildfly.arquillian}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.logmanager</groupId>
<artifactId>log4j-jboss-logmanager</artifactId>
</exclusion>
<!-- This exclusion is needed to be able to setup the project in Windows:
it otherwise includes transitive dependency to the JDK JConsole -->
<exclusion>
<artifactId>wildfly-patching</artifactId>
<groupId>org.wildfly</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<!-- Allows to find the absolute path to dependencies -->
<groupId>org.bitstrings.maven.plugins</groupId>
<artifactId>dependencypath-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>set-all</id>
<goals>
<goal>set</goal>
</goals>
<configuration>
<propertySets>
<propertySet>
<includes>
<include>org.jboss.byteman:byteman:jar</include>
</includes>
</propertySet>
</propertySets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<runOrder>alphabetical</runOrder>
<systemPropertyVariables>
<!-- See HSEARCH-1444 -->
<hibernate.service.allow_crawling>false</hibernate.service.allow_crawling>
<com.sun.management.jmxremote>true</com.sun.management.jmxremote>
<org.hibernate.search.enable_performance_tests>${org.hibernate.search.enable_performance_tests}</org.hibernate.search.enable_performance_tests>
</systemPropertyVariables>
<additionalClasspathElements>
<!-- Needed by Byteman to load the agent on demand -->
<additionalClasspathElement>${jdk-toolsjar}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>unpack</id>
<phase>pre-integration-test</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${org.wildfly}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/node1</outputDirectory>
</artifactItem>
<!--
<artifactItem>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-modules</artifactId>
<version>${project.version}</version>
<classifier>wildfly-10-dist</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/node1/wildfly-${org.wildfly}/modules</outputDirectory>
</artifactItem>
-->
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<!-- Copy the AS configuration files so we can use our custom configurations -->
<execution>
<id>configure-as-node-node1</id>
<!-- <phase>pre-integration-test</phase> -->
<phase>integration-test</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/node1/wildfly-${org.wildfly}</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${basedir}/src/wildflyConfig</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
./src/test/resources/arquillian.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate Search, full-text search for your domain model
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<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">
<defaultProtocol type="Servlet 3.0" />
<!-- Uncomment in order to inspect deployments -->
<!--
<engine>
<property name="deploymentExportPath">target/deployments</property>
</engine>
-->
<group qualifier="Grid" default="true">
<container qualifier="container.active-1" mode="suite" default="true">
<configuration>
<property name="jbossHome">${project.build.directory}/node1/wildfly-${org.wildfly}</property>
<!-- Needed for JMS tests -->
<property name="serverConfig">standalone-full-testqueues.xml</property>
<property name="javaVmArguments">-javaagent:${byteman.agent.path}=script:${byteman.script.path} -Xmx512m -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1</property>
<!-- To debug the Arquillian managed application server: -->
<!-- property name="javaVmArguments">-javaagent:${byteman.agent.path}=script:${byteman.script.path} -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y -Xmx512m -Dorg.jboss.remoting-jmx.timeout=300 -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1</property -->
</configuration>
</container>
</group>
</arquillian>
./src/test/java/org/hibernate/search/jsr352/DeploymentTest.java
package org.hibernate.search.jsr352;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
public class DeploymentTest {
@Deployment
public static WebArchive createDeployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addPackages(true, "io.github.mincongh")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsResource("META-INF/batch-jobs/mass-index.xml");
System.out.println(war.toString(true));
return war;
}
@Test
public void startJob() {
// TODO: add tasks here
}
}
也许您混淆了 Maven Surefire 和 Failsafe 插件。
DeploymentTest
以上是单元测试,不是 IT 测试,将由 Surefire 执行。因此,如果您希望使用 maven-dependency-plugin
解压 WildFly,您需要将 unpack
绑定到 <phase>process-test-classes</phase>
等阶段,该阶段将在 Surefire 在 [=14] 之前执行=]相.
Maven 生命周期参考:
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference