적절한 통합 테스트를 만들고 다음 설정을 사용하여 메이븐 빌드 중에 통합 테스트를 수행하는 것이 좋습니다.
tomcat을 다운로드하거나 저장소에서 이슈를 사용해야하는 경우 다음 부분을 사용할 수 있습니다.
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<wait>false</wait>
<container>
<containerId>tomcat${tomcat.major}x</containerId>
<zipUrlInstaller>
<url>http://archive.apache.org/dist/tomcat/tomcat-${tomcat.major}/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.tar.gz</url>
<extractDir>${project.build.directory}/extract/</extractDir>
<downloadDir>${project.build.directory}/download/</downloadDir>
</zipUrlInstaller>
<output>${project.build.directory}/tomcat${tomcat.major}x.log</output>
<log>${project.build.directory}/cargo.log</log>
</container>
<configuration>
<home>${project.build.directory}/tomcat-${tomcat.version}/container</home>
<properties>
<cargo.logging>high</cargo.logging>
<cargo.servlet.port>9080</cargo.servlet.port>
<cargo.tomcat.ajp.port>9008</cargo.tomcat.ajp.port>
</properties>
</configuration>
</configuration>
다음 부분은 응용 프로그램을 시작하여 주어진 tomcat (jetty와의 작업)에 배포하는 데 사용됩니다.
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
가장 좋은 것은이 앱을 호출 할 수있는 별도 받는다는 모듈에 구성 등의이 종류를 넣어하는 것입니다 (:
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>deploy</goal>
</goals>
<configuration>
<deployer>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>mod-war</artifactId>
<type>war</type>
<pingURL>http://localhost:9080/mod-war</pingURL>
<pingTimeout>30000</pingTimeout>
<properties>
<context>mod-war</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</execution>
물론
마침내 통해 시작 서버를 중지합니다 통합 테스트 용). 에 통합 테스트 단계를 실행하고, 상기 구성을 개시한다 기간을 확인하는 반면 테스트 완전한 사이클 단순히
mvn verify
의해 호출 될 수있다. 그러나 통합 테스트 자체가 실행되도록 maven-failsafe-plugin을 구성하는 것이 중요합니다. 이에 대한 자세한 설명은 당신이 할 수있는 것은 http://tomcat.apache.org/maven-plugin-2.0/archetype.html를 참조 아파치 톰캣 Maven 플러그인과 원형을 생성하는 것입니다 Maven Unit- and Integration Test Guide
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</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>
</plugin>
가 왜 임베디드 바람둥이 볼 수 없습니다 http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/startup/Embedded.html –
가능한 복제본 [Howto embedded Tomcat 6?] (http://stackoverflow.com/questions/640022/howto-embed-tomcat-6) –
@ArunPJohny : 정확히 내가 뭘 찾고 있었는지 - 훌륭했습니다! 당신 (또는 원하는 사람)이 답변으로 올리면 받아 들일 것입니다. :) –