的Arquillian:反对部署的jar和运行测试
问题描述:
我有这样的Arquillian测试:的Arquillian:反对部署的jar和运行测试
@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class, "ejb.jar");// ejb.jar is in a resource root
}
@EJB
private DateService dateService;
@Test
public void shouldBeAbleToInjectEJB() throws Exception {
Assert.assertNotNull(dateService);
}
我看到的Arquillian及牡丹战争装饰,并试图将其部署到服务器:
19:18:34,773 WARN [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016012: Deployment deployment "test.war" contains CDI annotations but beans.xml was not found.
19:18:34,822 INFO [org.jboss.web] (ServerService Thread Pool -- 15) JBAS018210: Register web context: /test
19:18:35,010 INFO [org.jboss.as.server] (management-handler-thread - 2) JBAS018559: Deployed "test.war" (runtime-name : "test.war")
19:18:35,590 INFO [org.jboss.web] (ServerService Thread Pool -- 15) JBAS018224: Unregister web context: /test
19:18:35,617 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015877: Stopped deployment test.war (runtime-name: test.war) in 30ms
什么是错的?为何立即取消部署?
答
您还没有向Jar添加任何资源。有ejb的增加。 DateService是您创建并想要测试的EJB吗?它是否在您正在运行测试的项目中? Arquillian要求您将所有必需的资源添加到部署的jar中。
@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class, "ejb.jar").addClass(DateService.class);// ejb.jar is in a resource root
}
@EJB
private DateService dateService;
@Test
public void shouldBeAbleToInjectEJB() throws Exception {
Assert.assertNotNull(dateService);
}
它在0.5秒后被取消部署,也许这足以运行测试?它是完整的部署方法吗?在这种情况下,这应该会失败。 –