2 Replies Latest reply on Jun 21, 2013 6:20 AM by pmensik

    Deploy two archives with same name

    pmensik

      Hello guys,

       

      is there a way how to use two deployment methods with the same Archive name?I have something like this

       

          @Deployment(testable = false, name = "classic", order = 1)

          public static WebArchive createDeployment() {

              return getArchive();

          }

       

          @Deployment(testable = false, name = "alternative", order = 2)

          public static WebArchive createAlternativeDeployment() {

              WebArchive archive = getArchive();

              archive.delete("WEB-INF/beans.xml");

              archive.addAsWebInfResource(new File("src/test/resources/beans.xml"));

              return archive;

          }

       

          private static WebArchive getArchive() {

              return ShrinkWrap.createFromZipFile(WebArchive.class, new File("target/CDIPortlet.war"));

          }

       

      and what I would like to (ideally) do is to execute classic deployment, then all test methods which operates on it, undeploy, execute alternative deployment and run rest of the tests. Is something like that possible?My problem is that I don't want to change my archive name because it matters to the portal environment and I would have to change other things just to make my one "alternative" test method work.

       

      Thanks a lot for tips.

        • 1. Re: Deploy two archives with same name
          aslak

          A common way of doing this is to have the @Test's defined in a abstract super class, then define the @Deployments in the sub class.

           

           

          @RunWith(Arquillian.class)
          public abstract AbstractTestBase {
          
            @Test
            public void x() {}
          }
          
          
          public class NoBeansXMLTestCase extends AbstractTestBase {
            @Deployment
            public static WebArchive() {
              ...
            }
          }
          
          
          public class WithBeansXMLTestCase extends AbstractTestBase {
            @Deployment
            public static WebArchive() {
              ...
            }
          }
          
          
          • 2. Re: Deploy two archives with same name
            pmensik

            Thanks Aslak, that worked:)