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