【发布时间】:2014-01-12 18:47:03
【问题描述】:
我将为 REST API 创建集成测试。所以,我想在测试之前运行 Jetty 并在测试之后停止它。我有每个测试的连接被拒绝错误。我的 POM.XML 的构建部分写在下面:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8010</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<contextPath>/performance-parser-service</contextPath>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanintervalseconds>0</scanintervalseconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<executions>
<execution>
<id>performance-parser-service-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
你能帮我解决这个问题吗?
最好的问候,
【问题讨论】:
-
您的测试是否指向正确的端口?我还记得看到一个插件可以让你保留一个开放端口并设置一个变量,你可以将它传递给你的容器和测试......
-
是的,我再次检查并测试指向 8010,同一个端口
标签: java maven junit jetty integration-testing