5

統合テストをhttp://localhost:8080/messagingで cargo の tomcat にヒットさせたいのですが、cargo (cargo-maven2-plugin:1.0.5) は私のメッセージング プロジェクトを /messaging-0.0.7-SNAPSHOT としてデプロイすることを好みます。 Tomcat 管理コンソールと target\tomcat6x\webapps ディレクトリに表示されます。

そこで、以下の行を cargo config に追加して、デフォルトのアーティファクトを取得することを考えてみました:

 <deployer>
  <deployables>
   <deployable>
     <properties>
     <context>/messaging</context>
    </properties>
   </deployable>
  </deployables>
 </deployer>

しかし、そうではありません。target\tomcat6x\webapps ディレクトリにmessagingまたはmessaging-0.0.7-SNAPSHOTが表示されないため、試みさえしません。

次のように設定すると、同じことが起こります。

<configuration>
  <type>standalone</type>
 <wait>false</wait>
 <properties>
  <cargo.servlet.port>8080</cargo.servlet.port>
  <cargo.logging>high</cargo.logging>
 </properties>
 <deployer>
  <deployables>
   <deployable>
     <groupId>com.company.platform</groupId>
     <artifactId>messaging</artifactId>
     <type>war</type>
     <properties>
     <context>/messaging</context>
    </properties>
   </deployable>
  </deployables>
 </deployer>
</configuration>

完全なプラグイン構成は次のとおりです。

  <plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<executions>
 <execution>
  <id>start</id>
  <phase>pre-integration-test</phase>
  <goals>
   <goal>start</goal>
  </goals>
 </execution>
 <execution>
  <id>stop</id>
  <phase>post-integration-test</phase>
  <goals>
   <goal>stop</goal>
  </goals>
 </execution>
</executions>
<configuration>
  <type>standalone</type>
 <wait>false</wait>
 <properties>
  <cargo.servlet.port>8080</cargo.servlet.port>
  <cargo.logging>high</cargo.logging>
 </properties>
 <deployer>
  <deployables>
   <deployable>
     <properties>
     <context>/messaging</context>
    </properties>
   </deployable>
  </deployables>
 </deployer>
</configuration>

私の統合テストは次のようになります。

import junit.framework.TestCase;

import java.io.InputStream;
import java.net.URL;
import java.net.HttpURLConnection;
import java.sql.Time;

public class WebappTest extends TestCase
{
    public void testCallIndexPage() throws Exception
    {
        URL url = new URL("http://localhost:8080/messaging/");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.connect();
        assertEquals(200, connection.getResponseCode());
        InputStream is = connection.getInputStream();
        System.out.println(connection.getContent().getClass());

    }
}

続行するための最良の方法は何ですか? hxxp://localhost:8080/messaging-0.0.7-SNAPSHOT として正常にデプロイされることがわかっているので、テストを変更できますが、アーティファクト バージョンをすばやく取り込むにはどうすればよいでしょうか?

理想的には、貨物が正しく展開されるようにしたいのですが、その方法は不明です。

4

3 に答える 3

2

Deployablesタグはタグ内に入れるべきではありませんDeployer:

  <deployables>
   <deployable>
     <properties>
     <context>/messaging</context>
    </properties>
   </deployable>
  </deployables>
于 2016-12-21T16:18:37.647 に答える
2

Cargo Plugin Referenceから、

About WAR contexts

    Many containers have their specific files for redefining context roots (Tomcat 
has context.xml, JBoss has jboss-web.xml, etc.). If your WAR has such a file, the 
server will most probably use the context root defined in that file instead of the 
one you specify using the CARGO deployer.

この問題にぶつかる可能性はありますか?

また、コンテキスト名には先頭に/.

于 2011-01-19T02:36:45.867 に答える
1

finalName プロパティの設定はどうですか?

POMを設定<finalName>messaging</finalName>すると、これでうまくいくはずです。

于 2012-08-27T07:47:23.413 に答える