У меня есть проект Maven, который выполняет интеграционные тесты для другого веб-приложения. Это приложение развернуто и запущено в контейнере Tomcat.
Конфигурация для этого выполняется в «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>
Тестируемая (web-) заявка интегрируется в pom.xml моего проекта интеграционного тестирования как зависимость, поэтому у меня нет абсолютного или относительного пути к войне.
Моя проблема в том, что я не могу контролировать контейнер Tomcat во время выполнения моей программы. Хотя мой сценарий тестирования требует остановки и перезапуска контейнера (и перераспределения тестируемого приложения) между некоторыми тестами, например для проверки, есть ли еще активные потоки после остановки контейнера или все еще есть некоторые элементы моего приложения в кэше, ...
- Я хочу настроить запуск и остановку контейнера вне java , предпочтительно в pom.xml. Это возможно?
- Могу ли я указать, что определенные модульные тесты требуют перезапуска и выполнить это? Как?