gpt4 book ai didi

java - 自 Wildfly 15 起,Arquillian 托管测试不再有效

转载 作者:行者123 更新时间:2023-12-02 09:23:09 29 4
gpt4 key购买 nike

长期以来,我一直在使用 Wildlfy 进行 Arquillian 测试。目前我从 Wildfly 14 更新到 Wildfly 17。但是现在,所有 Arquillian 测试都失败了。我将其简化为单个 POM 和 arquillian.xml,主要取自网络中的教程和示例,结果发现,所有这些都适用于 Wildfly 14,而不适用于 Wildfly 15、16 或 17。

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.jboss.arquillian</groupId>
<artifactId>wildfly-arquillian-managed-example</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.5.0.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>8.2.1.Final</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>always</forkMode>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemPropertyVariables>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>

arquillian.xml:

<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

<container qualifier="wildfly" default="true">
<configuration>
<property name="jbossHome">D:\local_Source\Playground\Arquillian\wildfly-15.0.1.Final</property>
<property name="javaVmArguments">--add-modules=java.se</property>
</configuration>
</container>
</arquillian>

测试非常简单。它只是一个 @Test 方法,带有 System.out.println() 代码。

如上所述,更改arquillian.xml以使用Wildfly wildfly-14.0.1.Final,测试成功,但是从wildfly-15.0.1.Final开始,应用程序服务器正在启动,但对于测试方法我得到:

java.lang.IllegalArgumentException: ArquillianServletRunner not found. Could not determine ContextRoot from ProtocolMetadata, please contact DeployableContainer developer.
at org.jboss.arquillian.protocol.servlet.ServletUtil.determineBaseURI(ServletUtil.java:61)
at org.jboss.arquillian.protocol.servlet.ServletURIHandler.locateTestServlet(ServletURIHandler.java:54)
at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:76)
at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...

有人知道要更改什么才能让我的 arquillian 测试再次工作吗?

最佳答案

好的,我找到答案了!问题是 pom.xml 中的错误依赖项!

错误的是:

<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>8.2.1.Final</version>
<scope>test</scope>
</dependency>

正确的是:

<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>2.1.1.Final</version>
<scope>test</scope>
</dependency>

我刚刚在 google 上搜索了“wildfly-arquillian-container-management”并使用了最高版本号。但这一次,较高的数字是较旧的状态,可能与 Wildfly 8.2.1 同步,但不再与 Wildfly 15 或更高版本一起使用。

关于java - 自 Wildfly 15 起,Arquillian 托管测试不再有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58525302/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com