3

我无法获得成功的 Maven pom.xml 配置来启动 JBoss AS 7、部署战争工件,并让它等到工件成功部署后再开始运行集成测试。

我已经咨询过了...

我想使用已安装(和预配置)的 JBoss AS 7 容器。我不想让它一直运行。我想启动它,运行一些测试,然后关闭它。

我的环境:

  • cargo-maven2-plugin 1.3.1
  • jboss-as-7.1.1.Final
  • maven-failsafe-plugin 2.12.4

这是我的Failsafe配置...

        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven-failsafe-plugin.version}</version>
            <configuration>
                <forkMode>once</forkMode>
                <argLine>-javaagent:"${settings.localRepository}/org/springframework/spring-instrument/${spring.framework.version}/spring-instrument-${spring.framework.version}.jar"</argLine>
                <useSystemClassLoader>true</useSystemClassLoader>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <!-- Uncomment the line below if you want the build to fail when any integration test fails -->
                        <!-- <goal>verify</goal> -->
                    </goals>
                </execution>
            </executions>
        </plugin>

这是我的Cargo配置...

                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven2-plugin</artifactId>
                    <version>${cargo-maven2-plugin.version}</version>
                    <configuration>
                        <container>
                            <containerId>jboss71x</containerId>
                            <type>installed</type>
                            <home>${jboss71x.home}</home>
                            <output>${project.build.directory}/jboss71x/container.log</output>
                            <append>false</append>
                            <log>${project.build.directory}/jboss71x/cargo.log</log>
                        </container>
                        <configuration>
                            <type>standalone</type>
                            <home>${project.build.directory}/jboss71x/container</home>
                            <properties>
                                <cargo.jboss.configuration>default</cargo.jboss.configuration>
                                <cargo.rmi.port>1099</cargo.rmi.port>
                                <cargo.jvmargs>${servlet.container.jvmargs}</cargo.jvmargs>
                                <cargo.logging>high</cargo.logging>
                                <cargo.servlet.port>8080</cargo.servlet.port>
                            </properties>
                        </configuration>
                        <deployer>
                            <type>installed</type>
                            <deployables>
                                <deployable>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <type>war</type>
                                    <properties>
                                        <context>/ws</context>
                                    </properties>
                                    <pingURL>http://localhost:8080/ws/services</pingURL>
                                    <pingTimeout>30000</pingTimeout>
                                </deployable>
                            </deployables>
                        </deployer>
                    </configuration>
                    <!-- http://navinpeiris.com/2011/08/22/running-integrationacceptance-tests-in-jboss-7-using-cargo/ -->
                    <executions>
                        <execution>
                            <id>start-container</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>start</goal>
                                <goal>deploy</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>stop-container</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

当我想手动启动容器时,上面的配置效果很好mvn clean package cargo:run。但是在使用mvn clean integration-test.

提示?欢迎提出建议。

4

2 回答 2

0

上面的配置确实有效!

我不得不重新启动我的 shell,然后重新构建我的项目。我确实在容器的启动和停止时收到了弃用警告,但这是一个小问题。

[INFO] Building war: D:\workspaces\alstom-grid\Projects\SPP\SPP-MUI\spp-im-mui-ws\target\spp-im-mui-ws-1.0-SNAPSHOT.war
[INFO]
[INFO] --- cargo-maven2-plugin:1.3.1:start (start-container) @ spp-im-mui-ws ---
[WARNING] The <deployables> element under the <deployer> element is deprecated. Please use <deployables> under the plugin <configuration> instead.
[WARNING] The <deployables> element under the <deployer> element is deprecated. Please use <deployables> under the plugin <configuration> instead.
[WARNING] The <deployables> element under the <deployer> element is deprecated. Please use <deployables> under the plugin <configuration> instead.
[INFO]
[INFO] --- maven-failsafe-plugin:2.12.4:integration-test (default) @ spp-im-mui-ws ---
[INFO] Failsafe report directory: D:\workspaces\alstom-grid\Projects\SPP\SPP-MUI\spp-im-mui-ws\target\failsafe-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.spp.im.mui.jaxws.client.test.VirtualWebServiceClientITCase
Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.032 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 1

[INFO]
[INFO] --- cargo-maven2-plugin:1.3.1:stop (stop-container) @ spp-im-mui-ws ---
[WARNING] The <deployables> element under the <deployer> element is deprecated. Please use <deployables> under the plugin <configuration> instead.
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ spp-im-mui-ws ---
[INFO] Installing D:\workspaces\alstom-grid\Projects\SPP\SPP-MUI\spp-im-mui-ws\target\spp-im-mui-ws-1.0-SNAPSHOT.war to C:\.m2\repository\org\spp\im\mui\spp-im-mui-ws\1.0-SNAPSHOT\spp-im-mui-ws-1.0-SNAPSHOT.war

[INFO] Installing D:\workspaces\alstom-grid\Projects\SPP\SPP-MUI\spp-im-mui-ws\pom.xml to C:\.m2\repository\org\spp\im\mui\spp-im-mui-ws\1.0-SNAPSHOT\spp-im-mui-ws-1.0-SNAPSHOT.pom

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:16.016s
[INFO] Finished at: Wed Nov 28 11:51:39 PST 2012
[INFO] Final Memory: 14M/256M
[INFO] ------------------------------------------------------------------------
于 2012-11-28T19:59:27.980 回答
0

由于我遇到了同样的问题,我想添加一些解释,这需要什么才能工作。

注意可部署部分中的 ping 属性。Cargo 将在继续之前重复调用给定的 URL 以获取可用性,但仅在达到超时之前。

 <deployable>
   <groupId>${project.groupId}</groupId>
   <artifactId>${project.artifactId}</artifactId>
   <type>war</type>
   <properties>
     <context>/example-app</context>
   </properties>
   <pingURL>http://localhost:8080/example-app/ping</pingURL>
   <pingTimeout>30000</pingTimeout>
 </deployable>

要使您的应用程序可 ping,您必须提供一个 ping 端点。您可以将 JAX-RS 与 RestEasy 一起使用以轻松实现。

@Path("/ping")
public class PingResourceImpl {

    @GET
    @PermitAll // optional. Is needed if you protected your ressources f.e. with a SecurityInterceptor.
    public Response ping() {
        return Response.ok().build();
    }
}

确保正确配置 servlet 映射。

<servlet>
    <servlet-name>Resteasy</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Resteasy</servlet-name>
    <url-pattern>/ping</url-pattern>
</servlet-mapping>
于 2013-10-31T11:46:26.177 回答