изменение пути развертывания грузового плагина maven - PullRequest
4 голосов
/ 19 января 2011

Я хочу, чтобы мой интеграционный тест поразил грузового кота в http://localhost:8080/messaging, но Cargo (cargo-maven2-plugin: 1.0.5) предпочитает использовать мой проект обмена сообщениями как /messaging-0.0.7-SNAPSHOT в консоли администратора tomcat и в каталоге target \ tomcat6x \ webapps.

Поэтому я попытался добавить эти строки в конфигурацию груза, полагая, что он подберет артефакт по умолчанию:

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

но это не так. Он даже не пытается, так как я не вижу сообщения или сообщений-0.0.7-SNAPSHOT в каталоге target \ tomcat6x \ webapps.

То же самое происходит, когда я настраиваю его так:

<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, я мог изменить тест, но каким был бы быстрый способ получить версию артефакта?

В идеале, я бы хотел, чтобы груз правильно его развернул, но неясно, как.

Ответы [ 3 ]

2 голосов
/ 19 января 2011

Из Справочник грузовых плагинов ,

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.

Не могли бы вы решить эту проблему?

Кроме того, я думаю, что имя контекста не должно иметь ведущего /.

1 голос
/ 21 декабря 2016

Deployables тег не должен идти внутрь Deployer тег:

  <deployables>
   <deployable>
     <properties>
     <context>/messaging</context>
    </properties>
   </deployable>
  </deployables>
1 голос
/ 27 августа 2012

А как насчет установки свойства finalName?

Если вы установите <finalName>messaging</finalName> в POM, это должно сработать.

...