Arquillian找不到Wildfly - org.jboss.arquillian.container.spi.client.container.LifecycleException

时间:2017-04-05 17:47:45

标签: gradle jboss wildfly jboss-arquillian

我正在尝试在Wildfly托管容器上运行Arquillian测试。

以下是Arquillian的部署和测试:

@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);
    }
}

我没有任何arquillian.xml文件,所以我依靠JBOSS_HOME环境变量让Arquillian找到我的Wildfly:

echo $JBOSS_HOME
/opt/wildfly-8.2.1.Final

所有这个过程都是由Gradle构建启动的,所以这里是我build.gradle文件最相关的依赖项:

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'
} 

如果我在Windows上运行此设置,我的JBOSS_HOME指向有效的Wildfly安装,它运行正常,但当我在Ubuntu Server 14.04上重现相同的设置时,我收到错误下面:

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

我尝试在Windows上重现此行为,并意识到当我删除环境变量JBOSS_HOME时会发生这种情况,因此Arquillian找不到我的容器,而是回到Ubuntu,即使该变量存在,它也不起作用。

有什么想法吗?提前谢谢。

0 个答案:

没有答案