Изменение пути развертывания грузового плагина maven
Я хочу, чтобы мой интеграционный тест поразил грузового кота по адресу 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 ответа
Deployables
тег не должен идти внутрь Deployer
тег:
<deployables>
<deployable>
<properties>
<context>/messaging</context>
</properties>
</deployable>
</deployables>
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.
Не могли бы вы решить эту проблему?
Кроме того, я думаю, что имя контекста не должно быть ведущим /
,
Как насчет установки свойства finalName?
Если вы установите <finalName>messaging</finalName>
в вашем POM это должно сработать.