【问题标题】:Arquillian can't communicate with remote JBoss Wildfly, insist on localhostArquillian 无法与远程 JBoss Wildfly 通信,坚持使用 localhost
【发布时间】:2017-08-07 09:54:27
【问题描述】:

我们切换到 JBoss EAP 7,它与 JBoss Wildfly 10 大致相同。

这是 Arquillian 的新版本,现在我正在尝试测试所有内容。

测试在我的本地机器上运行,在本地 JBoss 上运行。但是,当我尝试在应该连接到 JBoss 服务器(另一台机器)的构建服务器上运行它们时,测试失败了。

我可以在服务器日志中看到测试 WAR 在测试后部署和删除。但是,在测试过程中,Arquillian 想要连接到 localhost:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 10.294 sec <<< FAILURE! - in itest.com.mydomain.esv.dds.bo.DDSDokumentI18NTest
testI18NKeys(itest.com.mydomain.esv.dds.bo.DDSDokumentI18NTest)  Time elapsed: 1.024 sec  <<< ERROR!
java.lang.IllegalStateException: Error launching test itest.com.mydomain.esv.dds.bo.DDSDokumentI18NTest public void com.mydomain.esv.util.testing.i18n.I18NTestBase.testI18NKeys()
...
Caused by: java.lang.IllegalStateException: Error launching request at http://localhost:8080/dds-adapter-api-itest/ArquillianServletRunner?outputMode=serializedObject&className=itest.com.mydomain.esv.dds.bo.DDSDokumentI18NTest&methodName=testI18NKeys. No result returned
    at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.executeWithRetry(ServletMethodExecutor.java:139)
    at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:99)
    at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

这是我的 arquillian.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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">
  <!-- Force the use of the Servlet 3.0 protocol with all containers, as it is the most mature -->
  <defaultProtocol type="Servlet 3.0" />

  <!-- Example configuration for a remote JBoss EAP instance -->
  <container qualifier="jboss-remote" default="true">
    <configuration>
      <property name="managementAddress">foobar.mydomain.com</property>
      <property name="managementPort">9990</property>
      <property name="username">admin</property>
      <property name="password">password</property>
    </configuration>
  </container>
</arquillian>

这些是我的相关依赖项(我们使用的是 JBoss EAP 7.0.4):

<dependency>
  <groupId>org.jboss.bom</groupId>
  <artifactId>jboss-eap-javaee7-with-tools</artifactId>
  <version>7.0.4.GA</version>
  <type>pom</type>
  <scope>import</scope>
</dependency>


<dependency>
  <groupId>org.jboss.shrinkwrap.resolver</groupId>
  <artifactId>shrinkwrap-resolver-depchain</artifactId>
  <type>pom</type>
  <scope>test</scope>
  <version>2.2.2</version>
  <exclusions>
    <exclusion>
      <groupId>javax.enterprise</groupId>
      <artifactId>cdi-api</artifactId>
    </exclusion>
    <exclusion>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.jboss.arquillian.junit</groupId>
  <artifactId>arquillian-junit-container</artifactId>
  <version>1.1.11.Final</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.wildfly.arquillian</groupId>
  <artifactId>wildfly-arquillian-container-remote</artifactId>
  <version>2.0.0.Final</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.jboss.arquillian.protocol</groupId>
  <artifactId>arquillian-protocol-servlet</artifactId>
  <version>1.1.11.Final</version>
  <scope>test</scope>
</dependency>

这是测试类:

@RunWith(Arquillian.class)
public class DDSDokumentI18NTest extends DDSArquillianI18NFieldEnumSupplierTest {

  /**
   * {@inheritDoc}
   */
  @Override
  protected FieldEnumSupplier getFieldEnumSupplier() {
    return new DDSDokument();
  }

}

及其基类:

@RunWith(Arquillian.class)
public abstract class DDSArquillianI18NFieldEnumSupplierTest extends FieldEnumSupplierI18NTestBase<I18NService> {

  @Inject
  private I18NService i18nService;

  /**
   * Creates the deployment for the test.
   * @return the deployment
   */
  @Deployment
  public static Archive<?> createDeployment() {
    return DDSArquillianIntegrationTest.createCoreDeployment();
  }

  /**
   * {@inheritDoc}
   */
  @Override
  protected Map<String, String> getI18NKeysAndValues() {
    final Map<I18NLanguage, Map<String, String>> values = getService().getValues(DDSArquillianI18NTest.I18N_PATTERNS);
    return values.get(I18NLanguage.GERMAN);
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public I18NService getService() {
    return this.i18nService;
  }

}

我做错了什么?

【问题讨论】:

  • 你的容器适配器依赖是什么?
  • 我添加了相关的依赖,感谢您的帮助!
  • 如果能看到测试课的全貌,那就太好了。
  • 好的,因为我们有一个围绕我们的 Arquillian 测试类的生态系统,所以这有点困难 :-) 我要添加两个没有框架的类。尽管如此,这些测试仍然适用于本地 JBoss。
  • 对于任何来这里寻找答案的人:只要 JBoss 绑定到 0.0.0.0 就会出现问题,请参阅github.com/wildfly/wildfly-arquillian/pull/108

标签: jboss-arquillian


【解决方案1】:

答案可以在here找到。

需要在arquillian.xml中配置主机和端口。

<container qualifier="wildfly" default="true">
    <protocol type="Servlet 3.0">
        <property name="host">test.example.com</property>
        <property name="port">8181</property>
    </protocol>
</container>

【讨论】:

    猜你喜欢
    • 2014-07-29
    • 1970-01-01
    • 2016-03-17
    • 1970-01-01
    • 2016-09-27
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多