5 Replies Latest reply on Mar 2, 2012 4:57 AM by tomjenkinson

    Deploy a war dependency as part of an arquillian run

    tomjenkinson

      Hi,

       

      Not sure if this has been asked before but lets say I have:

       

      myApp

           pom.xml

           war1

                pom.xml

                src/main/java

                     foo.java

           war2

                pom.xml

                src/main/java

                     bar.java

                src/test/java

                     someArquillianTest.java

       

      Now, lets say that my test "someArquillianTest.java" requires the war1 to be deployed in order to work, is it to get arquillian to deploy war1?

       

      Thanks,

      Tom

        • 1. Re: Deploy a war dependency as part of an arquillian run
          aslak
          /* if you're not really doing in container testing you can add testable = false */
          @Deployment(name = "dep", order = 1 )
          public static JavaArchive jar() {...}
          
          
          @Deployment(order = 2)
          public static WebArchive war() {...}
          
          
          @Test  // will default to @OperatesOnDeployment with Default name (the one not named)
          public void should() {..}
          
          
          • 2. Re: Deploy a war dependency as part of an arquillian run
            aslak

            Missread your message a bit... same principle as the solution above (tho a WebArchive instead of a JavaArchive), but i guess the question is, how do you package a app outside of your module ?

             

            Couple of options comes to mind:

             

            * Using the new ShrinkWrap Resolver (soon to be released) you can package war1 based on maven cordinates and resolve it directly from workspace or maven repo depending on how it's being ran.

             

            * You could package it based on File ref outside of your module, e.g. addAsResource(new File("../war1/src/main/webapp"))

             

            * If war2 depend on war1 in maven wise, you can just create it using normal shrinkwrap stuff, or potentially introduce a 3 module that depend on them both where this test lives.

            • 3. Re: Deploy a war dependency as part of an arquillian run
              tomjenkinson

              Thanks Aslak,

               

              A few time sensitive issues have popped up since I posted this but one thing I want to try is:

               

                  @Deployment
                  public static Archive createTestArchive() {
                      MavenDependencyResolver resolver = DependencyResolvers.use(MavenDependencyResolver.class)
                              .loadMetadataFromPom("pom.xml");
                      return ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
                              .addClasses(War2EJB.class)
                              .addAsLibraries(resolver.artifact("foo:war1").resolveAsFiles());
                  }

               

              Do you think something like that might work, where foo:war1 resolves to a dependent .war? I guess I might have to provide an application.xml programmatically too (Maven builds it atm).

               

              I will try it once I have cleared a few issues.

               

              Thanks again for the feedback,

              Tom

              • 4. Re: Deploy a war dependency as part of an arquillian run
                aslak

                Yea, that should work.

                 

                (you can't add Classes to a EAR, but beyond that..

                • 5. Re: Deploy a war dependency as part of an arquillian run
                  tomjenkinson

                  Thanks Aslak, I will let you know how I get on.