I have a Maven project which executes integration tests for another web-application. This application is deployed and started within a tomcat container.
The configuration for this is done in the “cargo-maven2-plugin”:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<wait>false</wait>
<configuration>
<type>standalone</type>
<properties>
<cargo.hostname>${itest.hostname}</cargo.hostname>
<cargo.protocol>${itest.protocol}</cargo.protocol>
<cargo.servlet.port>${itest.port}</cargo.servlet.port>
<cargo.servlet.uriencoding>UTF-8</cargo.servlet.uriencoding>
<cargo.jvmargs>-Xmx1024m</cargo.jvmargs>
</properties>
</configuration>
<container>
<containerId>tomcat6x</containerId>
<home>${TEST_TOMCAT_HOME}</home>
</container>
<deployer>
<deployables>
<deployable>
<groupId>de.apllicationundertest</groupId>
<artifactId>apllicationundertest</artifactId>
<type>war</type>
<!--
This will test if the app is ready an throw an exception if
the integration tests start before deployment is finished
-->
<pingURL>${itest.protocol}://${itest.hostname}:${itest.port}/${itest.web.context}/main.html
</pingURL>
<pingTimeout>120000</pingTimeout>
<!-- Setting our context for the integration tests -->
<properties>
<context>${itest.web.context}</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
The (web-)apllication under tests is integrated as a dependency in the pom.xml of my integration test project, so I have no absolute or relative path to the war.
My problem is that I can't control the tomcat container during the runtime of my program. Though my test scenario requires the stopping and restarting of the container (and the redeployment of the apllication under test) between some tests, f.e. for checking if there are still some active Threads after the stopping of the container or if there are still some elements of my apllication in the cache,...
- I want to configure the starting and stopping of the container outside java, preferably in the pom.xml. Is that possible?
- Can I specify that certain unit tests require a restarting and execute that? How?