0

我正在尝试在 Maven 中使用 Arquillian 测试 JakartaEE 应用程序。由于生产应用程序应该在 Payara Micro 上运行,因此我选择了 Payara Micro Remote 依赖项来与远程服务器进行通信:

<dependencies>
    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <version>1.6.0.Final</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>fish.payara.arquillian</groupId>
        <artifactId>payara-micro-remote</artifactId>
        <version>2.2</version>
        <scope>test</scope>
    /dependency>
</dependencies>

当我执行测试时,出现以下错误:

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.325 s <<< FAILURE! - in com.mycompany.SomeTestClass
[ERROR] com.mycompany.SomeTestClass  Time elapsed: 1.325 s  <<< ERROR!
java.lang.IllegalArgumentException: Deployment failed. Payara Micro Deployer at http://localhost:8080/micro-deployer returned 404

我还尝试将 Payara Micro Deployer 部署到远程 Payara Micro Server,如下所示:

<plugin>
    <groupId>fish.payara.maven.plugins</groupId>
    <artifactId>payara-micro-maven-plugin</artifactId>
    <version>1.0.7</version>
    <configuration>
        <daemon>true</daemon>
        <commandLineOptions>
            <commandLineOption>
                <key>--deployFromGAV</key>
                <value>"fish.payara.arquillian,payara-micro-deployer,2.2"</value>
            </commandLineOption>
        </commandLineOptions>
    </configuration>
    <!-- ...some cother settings... -->
</plugin>

但这导致

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.34 s <<< FAILURE! - in com.mycompany.SomeTestClass
[ERROR] com.mycompany.SomeTestClass  Time elapsed: 1.34 s  <<< ERROR!
java.lang.IllegalArgumentException: Deployment failed. Payara Micro Deployer at http://localhost:8080/micro-deployer returned 403

我究竟做错了什么?是否有任何关于如何使用 Payara Micro Remote 使 Arquillian 工作的描述或示例项目?

我使用的 Payara Micro 版本是 5.194。

先感谢您!

4

1 回答 1

0

检查 Payara Micro 的部署路径后,这些路径是

GET     /payara-micro-deployer/application.wadl
DELETE  /payara-micro-deployer/application/{name}
PUT     /payara-micro-deployer/application/{name}

并深入研究 Payara Micro Remote 连接器配置的源代码(https://github.com/payara/ecosystem-arquillian-connectors/blob/master/payara-micro-remote/src/main/java/fish/payara/arquillian /container/payaramicro/remote/PayaraMicroRemoteContainerConfiguration.java )

    /**
     * Get path payara-micro-deployer resides at.
     * @return
     */
    public String getDeployerContextPath() {
        return deployerContextPath;
    }

我找到了解决方案。

我必须在 arquillian.xml 中配置 Payara Micro 的部署路径,如下所示:

<configuration>
    <property name="deployerContextPath">/payara-micro-deployer</property>
</configuration>
于 2020-04-28T09:46:16.013 回答