我想知道maven cargo插件运行嵌入式tomcat 7进行集成测试所需的最低配置是什么,请指教,谢谢。
发布于 2012-01-31 20:36:30
这应该足够了(指定端口是可选的,更改url以获得不同版本的tomcat7):
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.0</version>
<!-- minimal configuration to let adb run (mvn package org.codehaus.cargo:cargo-maven2-plugin:run) in a local tomcat -->
<configuration>
<container>
<containerId>tomcat7x</containerId>
<zipUrlInstaller>
<url>http://a-inet01:8100/apache-tomcat-7.0.25.zip</url>
</zipUrlInstaller>
</container>
<configuration>
<properties>
<cargo.servlet.port>1718</cargo.servlet.port>
</properties>
</configuration>
</configuration>
</plugin>然后mvn包org.codehaus.cargo:cargo-maven2-plugin:run (在包含“war”包的mavenproject上)将创建war,从给定的url下载tomcat,启动并部署war。如果你使用start,容器会在maven结束时停止(这是你在集成测试中会用到的):如果你想自动启动cargo,而不是补足:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
[Cargo plugin configuration goes in here]
</configuration>
</plugin>刚从cargo maven docu (http://cargo.codehaus.org/Starting+and+stopping+a+container)复制过来。这将在“集成测试”之前启动容器,并在测试之后停止它。
https://stackoverflow.com/questions/8820977
复制相似问题