i was wondering what is the minimum configuration needed for maven cargo plugin to run embedded tomcat 7 for integration testing, please advise, thanks.
Asked
Active
Viewed 2,835 times
0
-
Updated for Tomcat 9: https://stackoverflow.com/questions/59924534/how-to-run-embedded-tomcat-9-inside-maven-3-for-integration-testing-purposes – Alex R Feb 16 '20 at 21:16
1 Answers
0
that should be enough (specifying the port is optional, change the url to get a different version of 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>
than mvn package org.codehaus.cargo:cargo-maven2-plugin:run (on a mavenproject with packaging "war") will create the war, download the tomcat from given url, start it and deploy the war. if you use start the container is stopped if maven is finished (this one u will use in integration test): if you want to start cargo automatically than complement:
<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>
just copied from cargo maven docu (http://cargo.codehaus.org/Starting+and+stopping+a+container). this will start the container before "integration-test" and stop it after the tests.

dermoritz
- 12,519
- 25
- 97
- 185
-
Is this what they call "embedded" ? I have a similar question over at http://stackoverflow.com/questions/13701562/cargo-plugin-the-deployable-state-is-unknown with no takes. Ive seen mention that embedded is not supported in tomcat. – MikeW Dec 05 '12 at 20:59