0 Replies Latest reply on Dec 6, 2016 3:53 AM by vbaghdas

    Arquillian: Test deployment(s) for multiple project solution

    vbaghdas

      Hello,

       

      In a pretty simplified form I have following maven project structure:

       

      - Maven Project "UI", which contains UI logic. UI is startet via Spring Boot

      - Maven Project "Service API", which contains an interface for a REST Webservice

      - Maven Project "Service Impl", which contains implementation for the REST Webservice. Webservice is startet via Soring Boot

       

      "UI" uses "Service API", and "Service Impl" implements "Service API".

       

      "UI" and "Service Impl" are WAR - packaged. So, at a "normal" run, f,E. in Eclipse there would be 2 separate deployments for "UI" and "Service Impl", which are then startet in Tomcat one after another.

       

      I am testing integrative some execution path, going from "UI" to the "Service Impl".  What would be the generally the correct way to create test archive(s) for that test?

       

      Intiutive way would be trying to deploy both projects separately via 2 distinct @Deployment methods.

       

      I created a separate Maven project for Arquillian tests, pointing to "UI", "Service API" and "Service Impl".

       

      We are using exclusively Spring (no Java EE). Arquillian Test Class is enriched via @SpringAnnotationConfiguration with some Java Spring Config Class, which are lying partly in "UI" project and are used as well during "productive" run.

       

      I tried to deploy first only service impl project. My @Deployment method for "Service Impl" looks like this:

       

      @Deployment
        public static WebArchive createServiceDeployment() {
      
             WebArchive serviceArchive = ShrinkWrap .create(MavenImporter.class).configureFromFile(new File("C:/Users/vbaghdas/.m2/settings.xml"))
                 .loadPomFromFile("../dsuite-parent-demo-service/dsuite-parent-demo-service-impl/pom.xml")
                .importBuildOutput().as(WebArchive.class)
                     .addClasses(AuthenticationConfiguration.class,
                                 IntegrationDemoTestConfiguration.class,
                                 WebserviceClientConfiguration.class,
                                 JmsDestinationsConfiguration.class,
                                 JaxRsClientConfiguration.class, JmsConfiguration.class)
                    .addAsResource("application.properties")
                    .addAsLibrary(new File("C:/Users/vbaghdas/Desktop/spring-data-jpa-1.10.2.RELEASE.jar"))
                    .addAsLibrary(new File("C:/Users/vbaghdas/Desktop/spring-data-commons-1.12.2.RELEASE.jar"));
      
        System.out.println(serviceArchive.toString(true));
        return serviceArchive;
        }
      

       

      I have noticed, that from some reason Aqrquillian is mixing then jars from "UI" and "Service Impl" projects together in the result test archive. Despite of the fact, only imports from Service Impl. POM are given to be imported in the code above. As a result, during deployment / tomcat container starting UI project is starting via Spring Boot.

       

      Why Arquillian mix 2 project at that place?

       

      My test works in in-container mode and an embedded tomcat 8.

       

      Here my Arquillian deps:

       

      <!-- integration testing libraries -->
      
      
      
      
      <!-- integration testing libraries: org.jboss.arquillian -->
      
      
      
      
      <dependency>
      
      
      
      
      <groupId>org.jboss.arquillian.extension</groupId>
      
      
      
      <artifactId>arquillian-service-deployer-spring-3</artifactId>
      
      
      
      <version>1.0.0.Beta3</version>
      
      
      </dependency>
      
      
      
      
      
      
      
      <dependency>
      
      
      
      
      <groupId>org.jboss.arquillian.extension</groupId>
      
      
      
      <artifactId>arquillian-service-integration-spring-inject</artifactId>
      
      
      
      <version>1.0.0.Beta3</version>
      
      
      <pendency>
      
      
      
      
      
      
      
      <dependency>
      
      
      
      
      <groupId>org.jboss.arquillian.extension</groupId>
      
      
      
      <artifactId>arquillian-service-integration-spring-javaconfig</artifactId>
      
      
      
      <version>1.0.0.Beta3</version>
      
      
      </dependency>
      
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.jboss.arquillian.container</groupId>
      
      
      
      <artifactId>arquillian-container-spi</artifactId>
      
      
      
      <version>1.1.5.Final</version>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.jboss.arquillian.container</groupId>
      
      
      
      <artifactId>arquillian-container-test-spi</artifactId>
      
      
      
      <version>1.0.3.Final</version>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.jboss.arquillian.protocol</groupId>
      
      
      
      <artifactId>arquillian-protocol-servlet</artifactId>
      
      
      
      <version>1.0.3.Final</version>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.jboss.arquillian.testenricher</groupId>
      
      
      
      <artifactId>arquillian-testenricher-cdi</artifactId>
      
      
      
      <version>1.0.3.Final</version>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.jboss.arquillian.testenricher</groupId>
      
      
      
      <artifactId>arquillian-testenricher-resource</artifactId>
      
      
      
      <version>1.0.3.Final</version>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.jboss.arquillian.testenricher</groupId>
      
      
      
      <artifactId>arquillian-testenricher-initialcontext</artifactId>
      
      
      
      <version>1.0.3.Final</version>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.jboss.arquillian.testng</groupId>
      
      
      
      <artifactId>arquillian-testng-container</artifactId>
      
      
      
      <version>1.1.11.Final</version>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.jboss.arquillian.core</groupId>
      
      
      
      <artifactId>arquillian-core-api</artifactId>
      
      
      
      <version>1.1.4.Final</version>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.jboss.arquillian.container</groupId>
      
      
      
      <artifactId>arquillian-tomcat-embedded-8</artifactId>
      
      
      
      <version>1.0.0.CR7</version>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.jboss.arquillian.container</groupId>
      
      
      
      <artifactId>arquillian-tomcat-common</artifactId>
      
      
      
      <scope>test</scope>
      
      
      
      <version>1.0.0.CR7</version>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.jboss.arquillian.test</groupId>
      
      
      
      <artifactId>arquillian-test-spi</artifactId>
      
      
      
      <version>1.1.11.Final</version>
      
      
      </dependency>
      
      
      
      
      
      <!-- integration testing libraries: org.apache.tomcat -->
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.apache.tomcat.embed</groupId>
      
      
      
      <artifactId>tomcat-embed-core</artifactId>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.apache.tomcat.embed</groupId>
      
      
      
      <artifactId>tomcat-embed-jasper</artifactId>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.apache.tomcat.embed</groupId>
      
      
      
      <artifactId>tomcat-embed-logging-juli</artifactId>
      
      
      
      <version>8.5.2</version>
      
      
      </dependency>
      
      
      
      
      
      <dependency>
      
      
      
      <groupId>org.apache.tomcat</groupId>
      
      
      
      <artifactId>tomcat-dbcp</artifactId>
      
      
      
      <version>8.5.4</version>
      
      
      </dependency>
      
      
      
      
      
      <!-- integration testing libraries: org.jboss.shrinkwrap -->
      
      
      
      
      
      <dependency>
      
      
      
      
      <groupId>org.jboss.shrinkwrap.resolver</groupId>
      
      
      
      <artifactId>shrinkwrap-resolver-depchain</artifactId>
      
      
      
      <version>${version.shrinkwrap.resolvers}</version>
      
      
      
      <type>pom</type>
      
      
      </dependency>
      
      
      

      Here my arquillian.xml:

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://jboss.org/schema/arquillian"
        xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
      
      
        <extension qualifier="spring-deployer">
        <property name="autoPackage">true</property>
        <property name="springVersion">4.3.2.RELEASE</property>
        <property name="cglibVersion">3.2.4</property>
        <property name="useMavenOffline">true</property>
        </extension>
      
      
        <container qualifier="tomcat" default="true">
        <configuration>
        <property name="tomcatHome">target/tomcat-embedded-8</property>
        <property name="workDir">work</property>
        <property name="bindHttpPort">8888</property>
        <property name="unpackArchive">true</property>
        <property name="serverName">arquillian-tomcat-embedded-8</property>
        <property name="outputToConsole">true</property>
        </configuration>
      
      
        </container>
      
      
      </arquillian>