2 Replies Latest reply on Jan 11, 2015 6:43 AM by sai kiran nukala

    Test with Arquillian's ContainerController not deploying artifacts

    Steven Tay Newbie

      Hi,

       

      I'm having trouble deploying shrinkwrap's archives when I try to incoporate the ContainerController into my arquillian tests. As far as I can tell, I've done everything by the book and it seems that the @Deployment createDeployment() was invoked before the server had started up. Sample test class as below:

       

      @RunWith(Arquillian.class)
      public class TestEventDao {
      
           @Deployment
           public static EnterpriseArchive createDeployment() {
                // Some codes to generate archive
                return earFile;
           }
      
           @ArquillianResource
           protected ContainerController container;
      
           @EJB(mappedName = "java:app/my-module/EventDao")
           private EventDao dao;
      
           public void setUp() {
                if (!container.isStarted("my-jboss-qualifier")) {
                     // Sets a bunch of properties as config
                     container.start("my-jboss-qualifier", config);
                }
           }
      
           @Test
           public void persistEvent() {
                setUp();
                dao.create(...); // This will fail with NPE since it is not injected and it appears the class is operating outside of a deployed scope
           }
      }
      
      
      

       

      My arquillian.xml:

      <container qualifier="my-jboss-qualifier" default="true" mode="manual"></container>
      
      
      

       

      As a result, my beans are not injected resulting in NPE.

       

      If I remove the mode="manual" attribute from my arquillian.xml and comment off the setUp() call in the test then the everything runs fine. Does anyone have any idea what could be wrong with the test? Am I not using ContainerController correctly?

       

      Any help would be much appreciated.

       

      Thanks,

      Steven

        • 1. Re: Test with Arquillian's ContainerController not deploying artifacts
          Karel Piwko Master

          Hi Steven,

           

          deployment is always created before the container is started. What should matter though, is when that archive is deployed, which should be indeed executed after the server is started.

          Can you run with -Darquillian.debug=true to see when deployment happens?

           

          Few more things to try:

          1/ Inject @EJB as test method parameter - is it still null?

          2/ Inject CDI bean or something non EJB from archive - does this work?

          2/ Inject @ArquillianResource Deployer and deploy archive manually in setUp() method - any changes?

           

          Thanks,

           

          Karel

          • 2. Re: Test with Arquillian's ContainerController not deploying artifacts
            sai kiran nukala Newbie

            Hi Steven,

             

            I think you may have to specify the Arquillian that you are managing the deployments using "managed=false":

             

            @TargetsContainer("my-jboss-qualifier")

            @Deployment(managed=false, name="my-jboss-qualifier-deployment")

            public static EnterpriseArchive createDeployment() { 

                      // Some codes to generate archive 

                      return earFile; 

            }


            Thanks - Sai