【问题标题】:Maven command to run activemq before intergation tests在集成测试之前运行 activemq 的 Maven 命令
【发布时间】:2015-06-01 04:46:39
【问题描述】:

我需要在我的 maven 全新安装中运行 ActiveMQ,以便它启动 activemq 然后运行我的测试。我已将插件包含在 pom.xml 中,并添加了用于配置 mq 详细信息的 mq 配置文件。当我在一个控制台上运行 activeMq 并在其他控制台上运行 maven clean install(2 个单独的命令在 2 个单独的控制台上)时,它成功运行并且所有测试都通过了。但是有没有办法我可以在同一个控制台上使用 1 个命令运行 activemq 和全新安装?基本上我希望当我执行 mvn clean test install 时,它应该首先自动启动 mq,然后继续进行测试...

我尝试过使用 mvn activemq:run clean test installmvn clean test install activemq:run 等命令。但它要么进行全新安装,要么运行 activemq...

如何组合这 2 个命令(activemq:runmvn clean test install)?

【问题讨论】:

    标签: java maven testing jms activemq


    【解决方案1】:

    使用 <build><plugins> 构造附加 maven 目标和插件。

    <build>   
        <plugins>
            <plugin>
                <groupId>org.apache.activemq.tooling</groupId>
                <artifactId>maven-activemq-plugin</artifactId>
                <version>...</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <phase>process-test-classes</phase> <!-- or other phase before the test phase -->
                    </execution>
                </executions>    
            </plugin>
        </plugins>
    </build>
    

    【讨论】:

    • 完美...以及如何引用下的“pre-integration-test”阶段?
    • 你没有。看看maven.apache.org/guides/introduction/…。该阶段自动成为默认构建生命周期的一部分,将在您手动执行的测试阶段之前自动执行。
    • 我明白了......这很有意义......现在我的activemq在我成功添加之前运行了。但是在我运行它时添加上述行后,我得到以下异常:-“插件 org.apache.activemq.tooling:maven-activemq-plugin:5.1 或其依赖项之一无法解决:未能找到 org. subversion.xx.xx.xx/svn/repos/mavenRepository/trunk/… 中的 apache.activemq.tooling:maven-activemq-plugin:jar:5.1 已缓存在本地存储库中,直到 XXX-m2-repo 的更新间隔已过或强制更新后才会重新尝试解析 ->"
    • 非常感谢您的帮助。我很感激。它现在可以工作,我的测试正在使用 activeMQ 实例来运行集成测试。我正在使用 uri :- "tcp://localhost:61616?useJmx=false&persistent=false&fork=true" 和相位作为 "pre-integration-test" 在我的 pom.xml 中。我删除了骆驼和码头依赖项,因为我不需要它。唯一的问题是,当任何消息传输到队列时,我会看到日志,并且看到各种端口号而不是 61616。例如,tcp://127.0.0.1:49921、tcp://127.0.0.1 :49920, tcp://127.0.0.1:49921/49827/49829 等..
    • 这被认为是有效的并且可以吗?我问是因为如果我在一个单独的实例中运行 activeMQ,我每次都会得到 61616 并且它不使用任何其他端口。
    猜你喜欢
    • 2014-01-12
    • 2013-03-20
    • 1970-01-01
    • 1970-01-01
    • 2014-06-21
    • 1970-01-01
    • 2020-01-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多