![](/img/trans.png)
[英]NullPointerExceptions throws while Arquillian and PowerMockito test runs
[英]Arquillian deploys application but test runs only locally
我正在使用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()
日志。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.