don't dream your life, live your dreams !
Cargo maven plugin allows you to deploy your webapp in a container (tomcat, jetty, jboss, …).
Here is an example that shows how to deploy your webapp in tomcat container and launch integration tests.
We ask maven to fire the goal ‘start’ at the phase ‘pre-integration-test’ to start the container.
This will have the benefit to be able to launch integration tests at the phase ‘integration_test’.
Then we will fire the goal ‘stop’ at the phase ‘post-integration-test’ to stop the container.
<plugins> (...) <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <version>${cargo-plugin.version}</version> <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> <!-- Container configuration --> <container> <containerId>tomcat8x</containerId> <type>installed</type> <artifactInstaller> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat</artifactId> <version>${tomcat.version}</version> <type>zip</type> <extractDir>${project.build.directory}/cargo/installs</extractDir> </artifactInstaller> </container> <!-- Configuration to use with the container or the deployer --> <configuration> <home>${project.build.directory}/catalina-base</home> <properties> <cargo.servlet.port>8080</cargo.servlet.port> <!-- valid values : low, medium or high --> <cargo.logging>medium</cargo.logging> <cargo.protocol>http</cargo.protocol> </properties> </configuration> <!-- Context configuration --> <deployables> <deployable> <properties> <context>/</context> </properties> </deployable> </deployables> </configuration> </plugin> (...) </plugins> |
When the container is started, we launch maven-failsafe-plugin goal ‘integration-test’ at phase ‘integration-test’.
<plugins> (...) <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>${maven-failsafe.version}</version> <executions> <execution> <id>integration-test</id> <goals> <goal>integration-test</goal> </goals> </execution> <execution> <id>verify</id> <goals> <goal>verify</goal> </goals> </execution> </executions> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> (...) </plugins> |
Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.
admin