我想让我的集成测试碰到货物的tomcat http://localhost:8080/messaging,但货物(cargo-maven2-plugin:1.0.5)更喜欢将我的消息传递项目部署为/messaging-0.0.7-SNAPSHOT,如tomcat管理控制台和目标\ tomcat6x \ webapps目录中所示。更改maven货物插件部署路径
所以,我想这些行添加到货物配置,搞清楚它会拿起默认神器:
<deployer>
<deployables>
<deployable>
<properties>
<context>/messaging</context>
</properties>
</deployable>
</deployables>
</deployer>
但事实并非如此。它甚至没有尝试,因为我在目标\ tomcat6x \ webapps目录中看不到消息传递或消息传递-0.0-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,我可以改变测试,但是什么是拉取工件版本的快捷方式?
理想情况下,我希望有货物正确配置,但目前还不清楚。
这是不是。有一个web.xml但不是一个context.xml – dols 2011-01-20 18:55:59