4

適切なサイズの Web プロジェクト用の統合テスト モジュールをセットアップしています。統合テスト モジュールは Web プロジェクト自体から分離されており、独自の pom があります。

アイデアは、maven-soapui-plugin を使用してリクエストを送信し、レスポンスを検証することです。soapui-plugin の設定は簡単です。ただし、jetty-maven-plugin にリモート リポジトリから戦争を展開するように指示する方法がわかりません。

私の理解が正しければ、jetty-maven-plugin には '<webApp>/<webApp>' というプロパティがあり、デプロイする war ファイルを指定できます。問題は、war ファイルがモジュール自体に存在しないことです。

Maven アセンブリ プラグインを使用して、プロジェクトの artifactId を介してリポジトリから戦争を取得できると聞いたことがありますが、どのように実行するかはまだわかりません。

ここに私が欲しいものの要約があります:

  1. たとえば、artifactId を介して、リポジトリなどから特定の戦争を取得します。
  2. この war を jetty-maven-plugin にデプロイします (goal deploy-war?)
  3. maven-soapui-plugin を取得してテストを実行し、統合テスト フェーズで結果を報告します。

ステップ 3 はカバーしたと確信していますが、ステップ 1 と 2 を達成する方法がよくわかりません。

どんな助けでも大歓迎です

4

2 に答える 2

6

戦争を取得してアンパックし、maven jetty プラグインですべてを動作させるために使用することはおそらく可能ですが、これはハックでちょっと醜いでしょう。dependency:copyよりクリーンなソリューションは、Maven Cargo プラグインを使用することです。これが私の提案です。以下は、座標を使用して WAR アーティファクトを取得する方法と、Cargo を使用して組み込みの Jetty コンテナーにデプロイする方法を示すサンプル 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>

最後に、soapui プラグインをintegration-testフェーズにバインドするだけです。

于 2010-04-20T19:37:03.850 に答える
4

ジョン、私は同じことをしていますが、Jetty プラグインでは別のアプローチを取りました。最終結果は同じだと思います。いくつかの Web サービス WAR に対して実行する統合テスト スイートを開発しています。フェーズで使用dependency:copyしてから、次のように構成された のリストを使用しています。package<contextHandler/>maven-jetty-plugin

<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>

さまざまな戦争を依存関係として宣言し、それを使用してディレクトリdependency:copy-dependenciesを設定することをお勧めします。wars-to-be-testedこれにより、Maven リアクターは、テストする戦争の後に統合テスト モジュールを構築する必要があることを理解できるようになります。私が遭遇した問題は、Jetty プラグインが、依存関係としてリストされているすべての war を「オーバーレイ」したいと考えていたことです (この概念は、実際に起こるまで聞いたこともありませんでした)。それが起こるのを許すことが何かを害するかどうかはわかりませんが、私はそれが好きではなかったので、私はそのdependency:copy方法を採用しました.

これは Cargo を使用するための単なる代替手段です。私はそれを自分で調べますが、別の方法を提供したかっただけです。

于 2010-12-09T13:40:38.490 に答える