Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-2090

Arquillian: @Deployment fails when using arquillian 1.3.0.Final+

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2018.5.0, 2.0.0.Final
    • Fix Version/s: 2.3.0.Final
    • Component/s: None
    • Labels:
    • Environment:

      Ubuntu 18.04 x64, openjdk 1.8.0.171
      Windows 10 x64, oracle jdk 1.8.0.161

    • Story Points:
      5
    • Steps to Reproduce:
      Hide

      https://gist.github.com/albihasani94/1c0e9cfdf546d4698fd54f017650e762

      • Add arquillian version 1.3.0.Final/1.4.0.Final in your pom.xml
      • Create a test designated to run with Arquillian
      • Specify a method that returns a ShrinkWrap archive to be used as deployment, either with a custom name or it will take "DEFAULT"
      • Run `mvn package` or `mvn test`
      • In the test phase, the deployment will throw an Exception: `java.lang.IllegalArgumentException: Can not add multiple org.jboss.shrinkwrap.api.Archive deployments with the same name: DEFAULT`
      Show
      https://gist.github.com/albihasani94/1c0e9cfdf546d4698fd54f017650e762 Add arquillian version 1.3.0.Final/1.4.0.Final in your pom.xml Create a test designated to run with Arquillian Specify a method that returns a ShrinkWrap archive to be used as deployment, either with a custom name or it will take " DEFAULT " Run `mvn package` or `mvn test` In the test phase, the deployment will throw an Exception: `java.lang.IllegalArgumentException: Can not add multiple org.jboss.shrinkwrap.api.Archive deployments with the same name: DEFAULT `

      Description

      When running integration testing with Arquillian, and you are using Arquillian versions newer than 1.2.1.Final, the deployment is likely to fail in the scenario I will describe below.

      I have specified a createArchive method annotated with @Deployment, and I have not annotated my test class with @DefaultDeployment.

      Up to Arquillian version 1.2.1.Final, the deployment that I have specified is running fine and the tests are run on this deployment.

      When you update the version of Arquillian to newer versions such as either 1.3.0.Final or 1.4.0.Final, the deployment archive cannot be created. This is due to an attempt by to create the same deployment twice.

      I have run some tests, between Wildfly Swarm 2018.5.0 and Thorntail 2.0 in conjuction with Arquillian 1.2.1 and Arquillian 1.3.0, and the results seem to indicate that testing works fine for either of the Thorntail versions on Arquillian 1.2.1, and it fails for both on Arquillian 1.3.0. In the later case the deployment that I have specified is attempting to be created two consecutive times, failing the second time because a deployment with the same name has already been created once.

      @RunWith(Arquillian.class)
      public class ApplicationTest {
      
          private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationTest.class);
          private static final String CREATE_DEPLOYMENT = "=====Create deployment=====";
          private static final String RETURN_DEPLOYMENT_ARCHIVE = "=====Return deployment archive: {}=====";
          private static final String CREATE_SWARM = "=====Create swarm=====";
      
          @Deployment(name = "arquillian_test_single_deployment")
          public static Archive createDeployment() {
              LOGGER.info(CREATE_DEPLOYMENT);
              JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
      
              deployment.addClass(HelloWorldEndpoint.class);
              deployment.addClass(JAXRSConfiguration.class);
      
              LOGGER.info(RETURN_DEPLOYMENT_ARCHIVE, deployment.getName());
              return deployment;
          }
      
          @CreateSwarm
          public static Swarm newContainer() throws Exception {
              LOGGER.info(CREATE_SWARM);
              return new Swarm();
          }
      
          @Test
          public void testMyService() {
              // test my service here
          }
      }
      
      -------------------------------------------------------
       T E S T S
      -------------------------------------------------------
      Running org.wildlfy.swarm.jaxrs.rest.ApplicationTest
      [main] INFO org.wildlfy.swarm.jaxrs.rest.ApplicationTest - =====Create deployment=====
      [main] INFO org.wildlfy.swarm.jaxrs.rest.ApplicationTest - =====Return deployment archive: 5ddcb622-7a86-43be-8f85-e51113f914a2.war=====
      [main] INFO org.wildlfy.swarm.jaxrs.rest.ApplicationTest - =====Create deployment=====
      [main] INFO org.wildlfy.swarm.jaxrs.rest.ApplicationTest - =====Return deployment archive: f79eac78-478b-436a-a045-d109421de651.war=====
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.442 sec <<< FAILURE! - in org.wildlfy.swarm.jaxrs.rest.ApplicationTest
      org.wildlfy.swarm.jaxrs.rest.ApplicationTest  Time elapsed: 0.441 sec  <<< ERROR!
      java.lang.IllegalArgumentException: Can not add multiple org.jboss.shrinkwrap.api.Archive deployments with the same name: arquillian_test_single_deployment
      	at org.jboss.arquillian.container.spi.client.deployment.DeploymentScenario.validateNotSameNameAndTypeOfDeployment(DeploymentScenario.java:290)
      	at org.jboss.arquillian.container.spi.client.deployment.DeploymentScenario.addDeployment(DeploymentScenario.java:41)
      	at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:82)
      

      I am aware that most of our tests use 1.1.x.Final, but I still think incompatibility with newer versions of Arquillian would be somewhat of an issue. If we are planning to keep Arquillian fixed at the old version, which I doubt would be the case, the problem would not arise.

      If we need to ensure compatibility with the newer versions of Arquillian, which I believe would be the case, I think I can investigate this further, to find the cause of the issue, and see whether a fix could be provided on Thorntail or Arquillian side.

      I am listing below two of the configurations I have tested:

      Thorntail 2.0 with Arquillian 1.3.0.Final (bug): https://gist.github.com/albihasani94/1c0e9cfdf546d4698fd54f017650e762
      Thorntail 2.0 with Arquillian 1.2.1.Final (working): https://gist.github.com/albihasani94/5413c3410fd027dd98688f7a1cb8ea7a

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mkouba Martin Kouba
                Reporter:
                albihasani94 Albin Hasani
              • Votes:
                4 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: