4

I'm trying to run Arquillian tests on a Wildfly managed container.

Here's the Arquillian's deployment and the test:

@RunWith(Arquillian.class)
public abstract class ArquillianTestCase {

    @Deployment
    public static WebArchive createDeployment() {

        /* Create the war file according to build.gradle. */
        WebArchive war = ShrinkWrap.create(EmbeddedGradleImporter.class)
                .forThisProjectDirectory().importBuildOutput()
                .as(WebArchive.class);

        /* Add the abstract test classes to war. */
        war.addClasses(ArquillianTestCase.class, SeleniumTestCase.class);

        /* Add selenium and its transitive dependencies to war's lib. */
        String seleniumJava = "org.seleniumhq.selenium:selenium-java:3.3.1";
        MavenResolverSystem resolver = Maven.resolver();
        File[] seleniumFiles = resolver.resolve(seleniumJava).withTransitivity()
                .asFile();
        war.addAsLibraries(seleniumFiles);

        return war;
    }
}

public class LoginTest extends ArquillianTestCase {

    @Test
    public void shouldRun() throws Exception {
        System.out.println("LoginTest!");
        Assert.assertTrue(true);
    }
}

I don't have any arquillian.xml file, so I rely on JBOSS_HOME environment variable to let Arquillian find my Wildfly:

echo $JBOSS_HOME
/opt/wildfly-8.2.1.Final

All of this process is started by a Gradle build, so here are the most relevant dependencies of my build.gradle file:

dependencies {

    /* Arquillian for managing the life cycle of the container. */
    testCompile 'org.jboss.arquillian.junit:arquillian-junit-container:1.1.10.Final'

    /* Arquillian and Wildfly integration. */
    testCompile 'org.wildfly:wildfly-arquillian-container-managed:8.2.1.Final'

    /* Arquillian and Gradle integration. */
    testCompile 'org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-gradle-depchain:2.2.6'

    /* Arquillian and Maven integration for resolving dependencies at runtime. */
    testCompile 'org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-maven:2.2.6'
    testCompile 'org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven:2.2.6'

    /* Selenium for front-end testing. */
    testCompile 'org.seleniumhq.selenium:selenium-java:3.3.1'
} 

If I run this setup on Windows with my JBOSS_HOME pointing to a valid Wildfly installation, it works fine, but when I reproduce the same setup on Ubuntu Server 14.04, I get the error below:

org.jboss.arquillian.container.spi.client.container.LifecycleException: Could not start container
    at org.jboss.as.arquillian.container.managed.ManagedDeployableContainer.startInternal(ManagedDeployableContainer.java:208)
    at org.jboss.as.arquillian.container.CommonDeployableContainer.start(CommonDeployableContainer.java:112)
    at org.jboss.arquillian.container.impl.ContainerImpl.start(ContainerImpl.java:199)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$8.perform(ContainerLifecycleController.java:163)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController$8.perform(ContainerLifecycleController.java:157)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.forContainer(ContainerLifecycleController.java:255)
    at org.jboss.arquillian.container.impl.client.container.ContainerLifecycleController.startContainer(ContainerLifecycleController.java:156)
     (omitted dozens of lines to improve readability)
Caused by: java.lang.NullPointerException
    at java.io.File.<init>(File.java:277)
    at org.jboss.as.arquillian.container.managed.ManagedDeployableContainer.startInternal(ManagedDeployableContainer.java:94)
    ... 84 more

I tried to reproduce this behavior on Windows and realised that it happens when I remove my environment variable JBOSS_HOME, so Arquillian doesn't find my container, but back on Ubuntu, even that variable exists, it doesn't work.

Any ideas? Thanks in advance.

Bruno Gasparotto
  • 671
  • 12
  • 31
  • I don't know a lot about gradle, but I know with maven on the maven-surefire-plugin you have to specify the environment variables in the configuration. Maybe you need to do something similar in gradle. – James R. Perkins Apr 06 '17 at 15:50
  • I don't believe this is the case here, I suspect that there is something related to the environment going on. However, I tried to specify it in Gradle with `ext.jbossHome = '/opt/wildfly-8.2.1.Final'` but it didn't work. – Bruno Gasparotto Apr 06 '17 at 16:42
  • Hmm... ...well it defaults to `System.getenv("JBOSS_HOME")` and if not found uses `System.getProperty("jboss.home")`. If one of those are set it should work. – James R. Perkins Apr 07 '17 at 15:39
  • Is it `jbossHome` or `jboss.home`? Because I've set `jbossHome` in Gradle even that I had `JBOSS_HOME` on my system, but it is still not working. – Bruno Gasparotto Apr 10 '17 at 12:47
  • The system property is `jboss.home` the environment variable is `JBOSS_HOME`. – James R. Perkins Apr 10 '17 at 14:53
  • 2
    @BrunoGasparotto If you were able to resolve this issue it would be of great help to the community if you could please share how you fixed it, I'm facing a similar issue on mac i have set in my build.gradle ext.jbossHome = hasProperty('jbossHome') ? jbossHome : "/Users/Downloads/wildfly-17.0.1.Final" but running into exception "org.jboss.arquillian.container.spi.ConfigurationException: jbossHome 'null' must exist" – user2359997 Oct 12 '19 at 18:16

0 Answers0