5 Replies Latest reply on Sep 14, 2010 7:34 PM by Michael Schuetz

    Multiple @Deployments?

    Michael Schuetz Novice

      Hi to all,

       

      is there a way to use multiple @Deployment's within one Arquillian test?

       

      What do I want:

      Testing EJB which requires ResourceAdapter which itsef is packaged as RAR.

       

      So I would need to deploy:

      1) external datasource

      2) RAR

      3) EAR, containing EJB-JAR with my test classes

       

      Hm, it wouldn't be a realisitc test szenario to put everything into one single EAR.

       

      So, is there a nicer approach than Single-EAR to solve this problem? Or could I use multiple @Deployment annotations within class hierarchy?

       

      BTW, at the moment, I solve this by putting DS an RAR into container by configuration script. But I want to test ResourceAdapter itself in combination with my common EJB tests.

       

       

      Thanks and regards

      Michael

        • 1. Re: Multiple @Deployments?
          Aslak Knutsen Master

          There is no way of doing multiple Deployments currently with the API.

           

          We are working on exposing a Deployer API so you can deploy any number of deployments when ever you want, but currently not supported.

           

          If you want to do it now, you can create a impl of ClassContextAppender and register e.g. a BeforeClass/AfterClass eventhandler that can scan your TestClass for a annotated method and deploy/undeploy the result using the DeployableContainer instance found in the Context.

           

          -aslak-

          • 2. Re: Multiple @Deployments?
            Dan Allen Master

            I also want to mention that it would be very helpful to know which container is being used by the test run when the deployments are being created. This would allow me to deploy something different to GlassFish vs JBoss AS (or Java EE 5 vs Java EE 6 vs a Servlet container)

             

            One way to accomplish this would be to inject a container identifier into the @Deployment method. Another would be to allow multiple @Deployment methods, each annotated with an execution environment qualifier (and perhaps one without a qualifier that's the fallback). Arquillian would then select the appropriate @Deployment method according to which container I am targeting. (See Proposal: Filtering out tests not compatible with target container).

             

            For example:

             

            @Deployment @JBossAS6Container
            public static Archive<?> createDeploymentForJBossAS()
            {
               // prepare for JBoss AS 6
            }
            
            @Deployment @GlassFishV3Container
            public static Archive<?> createDeploymentForGlassFish()
            {
               // prepare for GlassFish V3
            }
            
            1 of 1 people found this helpful
            • 3. Re: Multiple @Deployments?
              Dan Allen Master

              The declarative approach is obviously much better for tooling

              • 4. Re: Multiple @Deployments?
                Aslak Knutsen Master

                yea, we need support for this one way or the other..

                 

                https://jira.jboss.org/browse/ARQ-293

                • 5. Re: Multiple @Deployments?
                  Michael Schuetz Novice

                  Aslak, Dan - thanks a lot for your interesting replies.

                   

                  Dan Allen schrieb:

                   

                  @Deployment @JBossAS6Container
                  public static Archive<?> createDeploymentForJBossAS()
                  {
                     // prepare for JBoss AS 6
                  }

                   

                  Yeah, or even something like this:

                   

                  @Deployment @JavaEE6Compliant
                  public static Archive<?> createDeploymentForEE6Containers()
                  {
                     // prepare for Java EE 6 qualified containers
                  }

                   

                  This would lead a bit into Paxexam direction.

                  I do find this really usefull for internal testing of Open Source projects like JBoss Weld etc.

                   

                  Nevertheless, I personally wouldn't really need this feature within testing my projects as it is not so common to support multiple containers.

                   

                  What I would really appreciate is the multiple @Deployment thing. This would help to build even more realistic integration tests. Could move some preconfiguration parts into test, directly.

                   

                   

                  Regards

                  Michael