当前位置: 首页 > 知识库问答 >
问题:

货物专家2插件在执行集成测试之前不会等待jboss as7启动

西门马鲁
2023-03-14

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

我已经咨询过。。。

  • http://navinpeiris.com/tag/jboss-as-7/
  • http://cargo.codehaus.org/Maven2插件参考指南#Maven2PluginReistrceGuide部署器

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

我的环境:

    < Li > cargo-maven 2-插件1.3.1 < li>jboss-as-7.1.1.Final < li>maven故障保护插件2.12.4

以下是我的故障保护配置。。。

        <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>

这是我对货物配置的内容...

                <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清洁集成测试构建CI期间,它没有达到预期的效果。

提示?欢迎提出建议。

共有2个答案

狄宗清
2023-03-14

上面的配置确实有效!

我必须重新启动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] ------------------------------------------------------------------------
慕容明煦
2023-03-14

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

请注意可部署部分中的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 与易用性结合使用,以便于实现。

@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>
 类似资料:
  • 我有一个用selenium进行单元测试和集成测试的项目。 当我用IntelliJ执行cucumber集成测试时,它工作得很好,您可以看到: 用Intellij执行cucumber集成测试 但是,当我执行mvn集成测试时,似乎没有发现任何联调: 故障保护输出 我定义了以下POM: > 文件夹结构是文件夹结构 mvn集成-测试输出https://drive . Google . com/file/d/

  • 下面是我真正的pom的一部分。集成测试的测试已经在@Test注释中分配了一个“集成”组。为了做小测试,我在测试阶段没有排除“集成”组。 当使用例如mvn验证或mvn安装构建时,集成测试在测试阶段执行,但不是验证或集成测试阶段。考试数量保持为0。不知何故,他们没有被捡起来。有人知道可能出了什么问题吗? 更新:将TestNG作为依赖项添加到故障保护插件没有帮助

  • 我对这段代码有一个问题,其中语句是在函数之前触发的,它返回0而不是正确的值。有没有办法在返回之前强制完成?我知道这是一个逻辑问题,因为如果我删除处的注释,它就可以正常工作。 如何在不使用或应用程序中的任何其他类型的超时?原始代码: 编辑代码: 这是StorageInformation类 从接口调用StorageInformation 我还尝试了r2rek的解决方案,得到了相同的结果 欢迎提出任何问

  • 在java maven jacoco中执行测试时出错:未能执行目标组织。阿帕奇。专家插件:maven surefire插件:2.12.4:测试 早上好我正在执行一个Maven项目,我使用NetBeans编写Java代码。当我尝试运行测试文件时,会出现以下错误: 这是我的pom.xml文件: 你能帮我吗?谢谢大家的可用性!

  • 我有一个加载页面,我想在其中对不相关的信息执行两个网络请求(rxjava)。在这两个请求完成之前,我不想进入下一页,即使其中一个或两个都失败了。 > 使用zip将请求绑定在一起。有没有办法不必被迫使用双函数,也不必返回null? 请求A和B有一个。doOnNext和。多恩。如果其中一个返回错误,zip observable是否继续?zip订阅服务器是否也会返回错误? 这是最好的方法吗?

  • 我正在进行集成测试,但由于某些原因,maven failsafe插件没有运行。下面是用于集成测试的概要文件。测试类的名称是AppSmokeTest。java@测试正在用于测试。 我看过多篇关于这个问题的帖子 我试着在build标签中运行插件。 我尝试添加 我也尝试过运行maven failsafe插件2.18.1版,因为我看到有人认为它对他们有用。