Arquillian部署应用程序,但测试仅在本地运行

时间:2016-12-16 14:02:57

标签: java junit websphere jboss-arquillian

我正在使用Websphere容器适配器(arquillian-was-remote-8)将EAR文件部署到远程容器并对其运行Arquillian测试。基本设置正常,Arquillian将EAR部署到Websphere容器。

但是,@Test方法似乎只在本地执行,所有System.out.println()语句都出现在我的本地shell上,我无法在服务器端日志文件中找到它们。此外,注入不起作用,myService对象始终为null

这是我的Arquillian测试课程:

@RunWith(Arquillian.class)
public class MyArquillianTest {

  @EJB
  MyService myService;

  @Deployment
  public static EnterpriseArchive createEarDeployment() {
    File f = new File("/path/to/application.ear");
    EnterpriseArchive ear = ShrinkWrap.createFromZipFile(EnterpriseArchive.class, f);

    // add test jar to ear (https://developer.jboss.org/thread/200399)
    JavaArchive testJar = ShrinkWrap.create(JavaArchive.class);
    testJar.addClass(LeasmanServiceBeanIntTest.class);
    return ear.addAsLibrary(testJar);
  }

  @Test
  public void test() {
    System.out.println("TEST!");
    if (myService != null) {
      myService.getServerStatus();
    }
    else {
      System.out.println("Injection failed :(");
    }
  }
}

我还试图不部署整个EAR,但是包含在其中的单个WAR文件,但总是得到与部署归档相同的结果,注入的对象仍然是null而没有System.out.println()出现在服务器端日志中。

1 个答案:

答案 0 :(得分:0)

经过我发布this question的Arquillian论坛的大量调查和帮助后,我终于发现我错误地使用Java 8而不是IBM来构建arquillian-was-remote-8 Java(1.6)是我WAS8_HOME的一部分。