我有一个 Maven Web 应用程序(Spring+ApacheCXF webservices)和几个集成测试(*IT.java)。我想通过使用 cargo-maven 插件部署战争文件来使用故障安全插件运行集成测试。
这是我的pom配置:
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.3</version>
<configuration>
<container>
<containerId>jboss51x</containerId>
<home>C:/jboss-5.1.0.GA</home>
<append>false</append>
<log>${project.build.directory}/logs/jboss51x.log</log>
<output>${project.build.directory}/logs/jboss51x.out</output>
<timeout>300000</timeout>
</container>
<configuration>
<type>existing</type>
<home>C:/jboss-5.1.0.GA/server/default</home>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.jboss.configuration>default</cargo.jboss.configuration>
<cargo.rmi.port>1099</cargo.rmi.port>
<cargo.logging>high</cargo.logging>
</properties>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>admin-services</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deployer-deploy</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>deployer-undeploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>failsafe-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugin>
但问题是 cargo 插件部署了 WAR 文件,并且故障安全插件立即尝试执行 IntegrationTests,到那时应用程序尚未部署,因此测试失败。
使用相同的配置,我可以成功分两步运行集成测试。1. 执行 cargo:deployer-deploy 2. 执行集成测试
无论如何只有在货物插件部署应用程序后才能触发故障安全插件?