Wildfly port offset not working with Arquillain

2019-03-31 20:50发布

问题:

Up until now I've been running my intergration tests using JBOSS AS 7 managed with Arquillian Testing framework. I have been setting the offset by 100 This has been working fine but now I want to transfer my integration tests to Wildfly AS managed but the same tests fail with the following error:

arquillianBeforeSuite(com.aeroflex.teravm.selfinstall.core.ejb.SampleServiceIT) Time elapsed: 130.749 sec <<< FAILURE! org.jboss.arquillian.container.spi.client.container.LifecycleException: Could not start container

Here is my 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">
<!-- <defaultProtocol type="Servlet 3.1"/> -->
<container qualifier="wildfly-managed" default="true">
<configuration>
<property name="jbossHome">target/wildfly-8.0.0.Final</property>
<property name="serverConfig">standalone.xml</property>
<property name="outputToConsole">true</property>

<property name="javaVmArguments">-Djboss.socket.binding.port-offset=100</property>
</configuration>
</container>
</arquillian>

and a sample of one of the integration tests:

public class SampleServiceIT extends BaseServiceIT
{
    @Inject
    private SampleService sampleService;

    @Parameters(ARQUILLIAN_DATA_PROVIDER)
    @Test(groups = {"integration"})
    public void testGetNotExisting() throws ServiceException
    {
        Long id = new Long(5);
        SampleBean result = sampleService.getSampleObjectById(id);
        Assert.assertNull(result);
    }
}

If I don't change the port offset and just leave the defaults it works fine.

Thanks for any help in advance.

回答1:

I figured out the problem. I was missing the managementPort property which needs to be set.

<property name="managementPort">10090</property>

Full arquillian.xml file:

<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">
    <!-- <defaultProtocol type="Servlet 3.1"/> -->
    <container qualifier="wildfly-managed" default="true">
        <configuration>
            <property name="jbossHome">target/wildfly-8.0.0.Final</property>
            <property name="serverConfig">standalone.xml</property>
            <property name="outputToConsole">true</property>

            <property name="javaVmArguments">-Djboss.socket.binding.port-offset=100</property>
            <property name="managementPort">10090</property>
        </configuration>
    </container>
</arquillian>


回答2:

If some of you are running Arquillian tests like this through maven and you're using an embedded container, the javaVmArguments in the arquillian.xml will be ignored.

You need to the set the JVM arguments in the pom.xml:

<plugin>
  <artifactId>maven-failsafe-plugin</artifactId>
    <configuration>
      <argLine>-Djboss.socket.binding.port-offset=300</argLine>
         <systemPropertyVariables>
            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
         </systemPropertyVariables>

        <redirectTestOutputToFile>false</redirectTestOutputToFile>
  </configuration>
</plugin>

NOTE: This is the configuration for the maven-failsafe-plugin (i.e., if your tests are *IT.java). If your Arquillian tests are *Test.java, you'll want to configure the maven-surefireplugin.