4

좋은 크기의 웹 프로젝트를위한 통합 테스트 모듈을 설정 중입니다. 통합 테스트 모듈은 웹 프로젝트 자체와 분리되어 있으며 자체 테스트 모듈이 있습니다.jetty-maven-plugin이 저장소에서 검색된 war를 배포하는 방법은 무엇입니까?

아이디어는 maven-soapui-plugin을 사용하여 요청을 보내고 응답을 확인하는 것입니다. soapui-plugin을 설정하는 것은 번거롭지 않습니다. 그러나 나는 원격 저장소에서 전쟁을 전개하기 위해 jetty-maven-plugin에게 어떻게 말할 수 있는지 알아 내는데 어려움을 겪고있다.

올바르게 이해했다면, jetty-maven-plugin에는 배치 할 war 파일을 지정할 수있는 '< webApp/< webApp>'속성이 있습니다. 문제는 war 파일이 모듈 자체에 존재하지 않는다는 것입니다.

프로젝트 artifactId를 통해 저장소에서 war를 검색하기 위해 maven 어셈블리 플러그인을 사용할 수 있다고 들었지만, 아직 어떻게해야하는지에 대해 아직 알지 못합니다.

여기에 내가 원하는 걸의 요약이다 :

  1. 은 artifactId를 통해 예에서 저장소 등에서 특정 전쟁을 검색합니다.
  2. 이 전쟁을 jetty-maven-plugin에 배포하십시오 (목표 배포 - 전쟁)
  3. 테스트를 실행하고 통합 테스트 단계에서 결과를 다시보고하려면 maven-soapui-plugin을 가져 오십시오.

나는 3 단계가 덮여있어 확신합니다,하지만 난 어떤 도움을 크게 그것은 어쩌면 가능입니다

답변

5

를 감사 1 단계와 2

을 달성하는 방법을 아주 확실하지 오전 dependency:copy을 사용하여 전쟁을 검색하고, 그것을 풀고, 모든 것을 maven 부두 플러그인과 함께 작동 시키려면, 이것은 해키하고 다소 추한 것입니다. 더 깨끗한 해결책은 Maven Cargo plugin을 사용하는 것이고 이것은 나의 제안입니다. 아래는 그 좌표를 사용하여 WAR 이슈를 검색하는 방법을 보여주는 방법과 샘플 POM은화물을 사용하여 임베디드 부두 컨테이너에 배포합니다 :

<dependencies> 
    <dependency> 
    <groupId>war group id</groupId> 
    <artifactId>war artifact id</artifactId> 
    <type>war</type> 
    <version>war version</version> 
    </dependency> 
    ... 
</dependencies> 
... 
<build> 
    <plugins> 
    <plugin> 
     <groupId>org.codehaus.cargo</groupId> 
     <artifactId>cargo-maven2-plugin</artifactId> 
     <configuration> 
     <!-- Container configuration --> 
     <container> 
      <containerId>jetty6x</containerId> 
      <type>embedded</type> 
     </container> 
     <!-- Configuration to use with the container or the deployer --> 
     <configuration> 
      <deployables> 
      <deployable> 
       <groupId>war group id</groupId> 
       <artifactId>war artifact id</artifactId> 
       <type>war</type> 
       <properties> 
       <context>war context</context> 
       </properties> 
      </deployable> 
      </deployables> 
     </configuration> 
     <!-- Don't wait, execute the tests after the container is started --> 
     <wait>false</wait> 
     </configuration> 
     <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> 
    </plugin> 
    ... 
    </plugins> 
    ... 
</build> 

마지막으로, 단지 integration-test 단계에 soapui 플러그인을 결합한다.

+0

하이 파스칼. 팁 고마워. 이것은 정확히 내가 겪어 온 것 같습니다. 다시 한 번 감사드립니다! :-) – John

+0

@ John 여러분을 환영합니다. –

+0

매개 변수 deployables : org.codehaus.cargo.maven2.configuration.Configuration 클래스에 'deployables'을 찾을 수 없습니다. 필자의 경우 1.4.12 버전의화물에 대해 deploymentable 태그가 설정 범위를 벗어났습니다. http://stackoverflow.com/a/18061722/1488761 –

4

저는 똑같은 일을하고 있습니다, 존,하지만 제티 플러그인으로 다른 접근법을 택했습니다. 나는 최종 결과가 같다고 생각한다. 몇 가지 웹 서비스 WAR에 대해 실행할 통합 테스트 스위트를 개발 중입니다. 나는 package 단계에서 dependency:copy을 사용하고 다음 <contextHandler/>의 목록 maven-jetty-plugin에 대해 구성된 S :

<project> 
    … 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <executions> 
        <execution> 
         <id>copy-wars</id> 
         <phase>package</phase> 
         <goals> 
          <goal>copy</goal> 
         </goals> 

         <configuration> 
          <outputDirectory>${project.build.directory}/wars-to-be-tested</outputDirectory> 
          <stripVersion>true</stripVersion> 
          <artifactItems> 
           … 
           <artifactItem> 
            <groupId>groupId</groupId> 
            <artifactId>artifactId</artifactId> 
            <version>version</version> 
            <type>war</type> 
           </artifactItem> 
           … 
          </artifactItems> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 

      <plugin> 
       <groupId>org.mortbay.jetty</groupId> 
       <artifactId>jetty-maven-plugin</artifactId> 
       <version>7.1.3.v20100526</version> 
       <configuration> 
        … 
        <contextHandlers> 
         … 
         <contextHandler implementation="org.mortbay.jetty.plugin.JettyWebAppContext"> 
          <war>${project.build.directory}/wars-to-be-tested/artifactId.war</war> 
          <contextPath>/context</contextPath> 
         </contextHandler> 
        </contextHandlers> 
       </configuration> 

       <executions> 
        <execution> 
         <id>start-jetty</id> 
         <phase>pre-integration-test</phase> 
         <goals> 
          <goal>stop</goal> 
          <goal>run</goal> 
         </goals> 
         <configuration> 
          <scanIntervalSeconds>0</scanIntervalSeconds> 
          <daemon>true</daemon> 
         </configuration> 
        </execution> 

        <execution> 
         <id>stop-jetty</id> 
         <phase>post-integration-test</phase> 
         <goals> 
          <goal>stop</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

나는 의존성 등 다양한 전쟁을 선언하고 wars-to-be-tested 디렉토리를 설정하는 dependency:copy-dependencies를 사용하는 것을 선호; 이것은 Maven 원자로가 테스트 할 전쟁 후에 내 통합 테스트 모듈을 빌드해야한다는 것을 알 수있게 해줍니다. 내가 겪었던 문제는 부두 플러그인이 의존성으로 나열된 모든 전쟁을 "오버레이"하고 싶다고 생각했다는 것입니다. 그 일이 일어나도록 허용하면 아무런 상처를 입을 지 모르겠지만 나는 그것을 좋아하지 않으므로 dependency:copy 방법을 사용했다.

이것은 Cargo를 사용하는 대신에 사용할 수 있습니다.나는 그 자신을 조사 할 것이지만, 나는 그것을하기위한 또 다른 방법을 제공하기를 원한다.