[arquillian-issues] [JBoss JIRA] (ARQ-1255) Multiple deployments is not working in Weld SE container

Karel Piwko (JIRA) jira-events at lists.jboss.org
Mon Jan 7 10:33:08 EST 2013


    [ https://issues.jboss.org/browse/ARQ-1255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12743828#comment-12743828 ] 

Karel Piwko commented on ARQ-1255:
----------------------------------

I think this is not Weld SE related. The problem is that @Inject annotation does not know where to inject from, as there are multiple deployment. This has no general solution, as there might be for instance classes implementing same EJB with different content in each of the @Deployment.

Does following work? There the injector should have enough content:

{code}
 @Test
    @OperateOnDeployment("beans-jar")
    public void singleDeploymentTest(@Inject Bean1 bean, @Inject Bean2 bean2) {
        assertNotNull(bean1);
        assertNotNull(bean2);
    }
{code}


                
> Multiple deployments is not working in Weld SE container
> --------------------------------------------------------
>
>                 Key: ARQ-1255
>                 URL: https://issues.jboss.org/browse/ARQ-1255
>             Project: Arquillian
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Weld Containers
>    Affects Versions: 1.0.0.CR5
>            Reporter: Antonin Stefanutti
>         Attachments: Bean1.java, Bean2.java, MultipleDeploymentArquilianCdiTest.java, OperateOnDeploymentArquilianCdiTest.java, pom.xml, test_case_1_stacktrace.txt, test_case_2_stacktrace.txt
>
>
> As described in [Multiple Deployments|https://docs.jboss.org/author/display/ARQ/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:*
> {code}
> @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);
>     }
> }
> {code}
> *Test case 2:*
> {code}
> @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);
>     }
> }
> {code}
> In both cases, the following exception is thrown:
> {code}
> 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]
> {code}
> Note that test case 2 is working when only {{@Deployment(name = "beans-jar")}} is declared.
> Test classes and the {{pom.xml}} are attached.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the arquillian-issues mailing list