-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
1.0.0.CR5
-
None
As described in Multiple Deployments, multiple @Deployment annotated methods can be declared in a test class. In addition, the @OperateOnDeployment annotation enables the selection of a particular deployment per test method.
However, when using Arquillian with a Weld SE container, the CDI container isn't deployed with the expected archives which ends up having DeploymentException thrown, as illustrated in the test cases below:
Test case 1:
@RunWith(Arquillian.class) public class MultipleDeploymentArquilianCdiTest { @Inject private Bean1 bean1; @Inject private Bean2 bean2; @Deployment(name = "bean1-jar") public static Archive<?> createBean1Jar() { return ShrinkWrap.create(JavaArchive.class).addClass(Bean1.class).addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } @Deployment(name = "bean2-jar") public static Archive<?> createBean2Jar() { return ShrinkWrap.create(JavaArchive.class).addClass(Bean2.class).addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } @Test public void multiDeploymentTest() { assertNotNull(bean1); assertNotNull(bean2); } }
Test case 2:
@RunWith(Arquillian.class) public class OperateOnDeploymentArquilianCdiTest { @Inject private Bean1 bean1; @Inject private Bean2 bean2; @Deployment(name = "beans-jar") public static Archive<?> createBeansJar() { return ShrinkWrap.create(JavaArchive.class).addClass(Bean1.class).addClass(Bean2.class).addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } @Deployment(name = "bean1-jar") public static Archive<?> createBean1Jar() { return ShrinkWrap.create(JavaArchive.class).addClass(Bean1.class).addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } @Deployment(name = "bean2-jar") public static Archive<?> createBean2Jar() { return ShrinkWrap.create(JavaArchive.class).addClass(Bean2.class).addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } @Test @OperateOnDeployment("beans-jar") public void singleDeploymentTest() { assertNotNull(bean1); assertNotNull(bean2); } }
In both cases, the following exception is thrown:
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Bean2] with qualifiers [@Default] at injection point [[field] @Inject private arquillian.test.OperateOnDeploymentArquilianCdiTest.bean2]
Note that test case 2 is working when only @Deployment(name = "beans-jar") is declared.
Test classes and the pom.xml are attached.