<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <artifactId>fluxnova-qa-integration-tests-engine</artifactId>
  <name>Fluxnova Platform - QA Integration Tests - Engine</name>

  <parent>
    <groupId>org.finos.fluxnova.bpm.qa</groupId>
    <artifactId>fluxnova-qa</artifactId>
    <version>2.0.3</version>
  </parent>

  <properties>
    <!-- Needs to be updated after a new WildFly release -->
    <wildfly.container.adapter.groupId>org.wildfly.arquillian</wildfly.container.adapter.groupId>
    <wildfly.container.adapter.version>2.2.0.Final</wildfly.container.adapter.version>

    <redirect.test.output>true</redirect.test.output>
  </properties>

  <!-- import shrinkwrap and arquillian bom for artifact versions,
    DO NOT CHANGE ordering, because we want shrinkwrap versions to be newer -->
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.jboss.shrinkwrap.resolver</groupId>
        <artifactId>shrinkwrap-resolver-bom</artifactId>
        <version>${version.shrinkwrap.resolvers}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>org.jboss.arquillian</groupId>
        <artifactId>arquillian-bom</artifactId>
        <version>${version.arquillian}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>

      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-framework-bom</artifactId>
        <version>${version.spring.framework}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>com.fasterxml.jackson</groupId>
        <artifactId>jackson-bom</artifactId>
        <version>${version.jackson}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <dependencies>
    <!-- set shrinkwrap artifacts -->
    <dependency>
      <groupId>org.jboss.shrinkwrap.resolver</groupId>
      <artifactId>shrinkwrap-resolver-depchain</artifactId>
      <scope>test</scope>
      <type>pom</type>
    </dependency>

    <dependency>
      <groupId>org.jboss.arquillian.junit</groupId>
      <artifactId>arquillian-junit-container</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jboss.arquillian.protocol</groupId>
      <artifactId>arquillian-protocol-servlet</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.spec</groupId>
      <artifactId>jboss-javaee-6.0</artifactId>
      <type>pom</type>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <artifactId>xalan</artifactId>
          <groupId>org.apache.xalan</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>javax.enterprise.concurrent</groupId>
      <artifactId>javax.enterprise.concurrent-api</artifactId>
      <version>1.0</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.finos.fluxnova.bpm.javaee</groupId>
      <artifactId>fluxnova-ejb-client</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.finos.fluxnova.bpm</groupId>
      <artifactId>fluxnova-engine-cdi</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <artifactId>fluxnova-engine</artifactId>
          <groupId>org.finos.fluxnova.bpm</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- fluxnova -->
    <dependency>
      <groupId>org.finos.fluxnova.bpm</groupId>
      <artifactId>fluxnova-engine</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.finos.fluxnova.bpm.dmn</groupId>
      <artifactId>fluxnova-engine-dmn</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>de.odysseus.juel</groupId>
          <artifactId>juel-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>de.odysseus.juel</groupId>
          <artifactId>juel-spi</artifactId>
        </exclusion>
        <exclusion>
          <groupId>de.odysseus.juel</groupId>
          <artifactId>juel-impl</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.finos.fluxnova.bpm</groupId>
      <artifactId>fluxnova-engine-spring</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <artifactId>fluxnova-engine</artifactId>
          <groupId>org.finos.fluxnova.bpm</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.finos.fluxnova.spin</groupId>
      <artifactId>fluxnova-spin-core</artifactId>
    </dependency>

    <dependency>
      <groupId>org.finos.fluxnova.spin</groupId>
      <artifactId>fluxnova-spin-dataformat-json-jackson</artifactId>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-joda</artifactId>
    </dependency>

    <!--
      needed for offline shrinkwrap,
      BOM must be installed before this module is built
    -->
    <dependency>
      <groupId>org.finos.fluxnova.bpm</groupId>
      <artifactId>fluxnova-bom</artifactId>
      <version>${project.version}</version>
      <type>pom</type>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.finos.fluxnova.bpm</groupId>
      <artifactId>fluxnova-core-internal-dependencies</artifactId>
      <version>${project.version}</version>
      <type>pom</type>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.finos.fluxnova.connect</groupId>
      <artifactId>fluxnova-connect-core</artifactId>
    </dependency>

    <!-- explicit Spring dependencies for applications
      that pack fluxnova-engine-spring -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
    </dependency>

     <!-- weld for CDI support on tomcat-->
    <dependency>
      <groupId>org.jboss.weld.servlet</groupId>
      <artifactId>weld-servlet</artifactId>
      <version>2.4.8.Final</version>
      <scope>test</scope>
    </dependency>

    <!-- required for TestWarDeploymentWithProcessEnginePlugin -->
    <dependency>
      <groupId>org.apache.groovy</groupId>
      <artifactId>groovy-jsr223</artifactId>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>**/*.xml</include>
          <include>**/*.properties</include>
        </includes>
      </testResource>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>false</filtering>
        <excludes>
          <exclude>**/*.xml</exclude>
          <exclude>**/*.properties</exclude>
        </excludes>
      </testResource>
    </testResources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <!-- install enhanced artifact -->
          <execution>
            <id>create-test-jar</id>
            <phase>package</phase>
            <goals>
              <goal>test-jar</goal>
            </goals>
            <configuration>
              <forceCreation>true</forceCreation>
              <excludes>
                <exclude>org/finos/fluxnova/bpm/integrationtest/util/TestConstants*</exclude>
                <exclude>org/finos/fluxnova/bpm/integrationtest/util/TestContainer*</exclude>
                <exclude>org/finos/fluxnova/bpm/integrationtest/util/TestProcessApplication*</exclude>
              </excludes>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>

    <profile>
      <id>wildfly26</id>
      <dependencies>
        <dependency>
          <!-- make sure this comes after runtime in the reactor build -->
          <groupId>org.finos.fluxnova.bpm.qa</groupId>
          <artifactId>fluxnova-qa-wildfly26-runtime</artifactId>
          <version>${project.version}</version>
          <scope>provided</scope>
          <type>pom</type>
        </dependency>
        <dependency>
          <groupId>${wildfly.container.adapter.groupId}</groupId>
          <artifactId>wildfly-arquillian-container-managed</artifactId>
          <version>${wildfly.container.adapter.version}</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <testResources>
          <testResource>
            <directory>src/test/resources-wildfly26</directory>
            <filtering>true</filtering>
          </testResource>
        </testResources>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-test-source</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>add-test-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>src/test/java-wildfly26</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
              <delimiters>
                <delimiter>${*}</delimiter>
              </delimiters>
              <useDefaultDelimiters>false</useDefaultDelimiters>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludes>
                <!-- HEMERA-2453 -->
                <exclude>**/JobExecutorRequestContextLocalInvocationTest.java</exclude>
                <exclude>**/*_OTHERS.java</exclude>
                <exclude>**/SpringPAExpressionResolvingTest.java</exclude>
                <exclude>**/SpringServletPALifecycleTest.java</exclude>
                <exclude>**/TestManagedDomain_JBOSS.java</exclude>
                <!-- CAM-1778 -->
                <exclude>**/TestWarDeploymentWithProcessEnginePlugin.java</exclude>
                <exclude>**/TestWarDeploymentWithProcessEnginePlugin.exclude</exclude>

                <exclude>**/SpringServletPATimerStartEventExpressionTest.java</exclude>
                <exclude>**/FeelEngineTest.java</exclude>
              </excludes>
              <redirectTestOutputToFile>${redirect.test.output}</redirectTestOutputToFile>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>wildfly26-domain</id>
      <dependencies>
        <dependency>
          <!-- make sure this comes after runtime in the reactor build -->
          <groupId>org.finos.fluxnova.bpm.qa</groupId>
          <artifactId>fluxnova-qa-wildfly26-runtime</artifactId>
          <version>${project.version}</version>
          <scope>provided</scope>
          <type>pom</type>
        </dependency>
        <dependency>
          <groupId>${wildfly.container.adapter.groupId}</groupId>
          <artifactId>wildfly-arquillian-container-domain-managed</artifactId>
          <version>${wildfly.container.adapter.version}</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <testResources>
          <testResource>
            <directory>src/test/resources-wildfly26-domain</directory>
            <filtering>true</filtering>
          </testResource>
        </testResources>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-test-source</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>add-test-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>src/test/java-wildfly26</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
              <delimiters>
                <delimiter>${*}</delimiter>
              </delimiters>
              <useDefaultDelimiters>false</useDefaultDelimiters>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <includes>
                <include>**/TestManagedDomain_JBOSS.java</include>
              </includes>
              <redirectTestOutputToFile>${redirect.test.output}</redirectTestOutputToFile>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>wildfly26-servlet</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-test-source</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>add-test-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>src/test/java-wildfly26-servlet</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludes>
                <!-- skip EE integration tests -->
                <exclude>**/cdi/**</exclude>
                <exclude>**/ejb/**</exclude>
                <exclude>**/context/**</exclude>
                <exclude>**/jar/**</exclude>
                <excludes>**/jboss/**</excludes>
                <excludes>**/SpringPAExpressionResolvingTest.java</excludes>
                <excludes>**/SpringServletPALifecycleTest.java</excludes>
                <exclude>**/BusinessRuleTaskVersionTagTest.java</exclude>
                <!-- CAM-1778 -->
                <exludes>**/TestWarDeploymentWithProcessEnginePlugin.java</exludes>

                <exclude>**/SpringServletPATimerStartEventExpressionTest.java</exclude>
                <exclude>**/FeelEngineTest.java</exclude>
              </excludes>
              <redirectTestOutputToFile>${redirect.test.output}</redirectTestOutputToFile>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>tomcat9</id>
      <dependencyManagement>
        <dependencies>
          <!-- import internal dependencies before JBoss to preserve internal versions, e.g. for JUnit -->
          <dependency>
            <groupId>org.finos.fluxnova.bpm</groupId>
            <artifactId>fluxnova-core-internal-dependencies</artifactId>
            <version>${project.version}</version>
            <scope>import</scope>
            <type>pom</type>
          </dependency>
          <dependency>
            <groupId>org.jboss.bom</groupId>
            <artifactId>jboss-javaee-6.0-with-tools</artifactId>
            <version>1.0.4.Final</version>
            <scope>import</scope>
            <type>pom</type>
          </dependency>
        </dependencies>
      </dependencyManagement>
      <dependencies>
        <dependency>
          <!-- make sure this comes after runtime in the reactor build -->
          <groupId>org.finos.fluxnova.bpm.qa</groupId>
          <artifactId>fluxnova-qa-tomcat9-runtime</artifactId>
          <version>${project.version}</version>
          <scope>provided</scope>
          <type>pom</type>
        </dependency>

        <dependency>
          <groupId>org.jboss.arquillian.container</groupId>
          <artifactId>arquillian-tomcat-managed-8</artifactId>
          <version>1.1.0.Final</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <testResources>
          <testResource>
            <directory>src/test/resources-tomcat</directory>
            <filtering>true</filtering>
          </testResource>
        </testResources>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-test-source</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>add-test-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>src/test/java-tomcat9</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludes>
                <!-- no EE stuff on tomcat :) -->
                <exclude>**/ear/**</exclude>
                <exclude>**/ejb/**</exclude>
                <exclude>**/jar/**</exclude>
                <exclude>**/transactions/**</exclude>
                <exclude>**/jpa/**</exclude>
                <!-- No EJB RequestContext available -->
                <exclude>**/JobExecutorRequestContextTest.java</exclude>
                <!-- Not supported by arquillian tomcat container -->
                <exclude>**/TestWarDeploymentWithBrokenBpmnXml.java</exclude>
                <exclude>**/TestDeploymentWithDroolsTaskFails.java</exclude>
                <exclude>**/TestProcessEnginesXmlFails.java</exclude>

                <exclude>**/TestWarDeploymentWithProcessEnginePlugin.java</exclude>

                <exclude>**/*_JBOSS.java</exclude>
                <exclude>**/EjbPALifecycleCallbacksTest.java</exclude>

                <exclude>**/PythonPaClassImportTest.java</exclude>

                <exclude>**/MigrationContextSwitchBeansTest.java</exclude>

                <exclude>**/ManagedJobExecutorTest.java</exclude>
              </excludes>
              <redirectTestOutputToFile>${redirect.test.output}</redirectTestOutputToFile>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>distro</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <dependencies>
        <dependency>
          <groupId>${wildfly.container.adapter.groupId}</groupId>
          <artifactId>wildfly-arquillian-container-managed</artifactId>
          <version>${wildfly.container.adapter.version}</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skipTests>true</skipTests>
              <redirectTestOutputToFile>${redirect.test.output}</redirectTestOutputToFile>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-test-source</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>add-test-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>src/test/java-wildfly26</source>
                  </sources>
                </configuration>
              </execution>
              <execution>
                <id>add-test-resource</id>
                <phase>generate-test-resources</phase>
                <goals>
                  <goal>add-test-resource</goal>
                </goals>
                <configuration>
                  <resources>
                    <resource>
                      <directory>src/test/resources-wildfly26</directory>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <!-- This profile is used by the ci server. The maven build on the
        ci server uses a local maven repository. This allows us to give the arquillian
        maven resolver access to the artifacts produced by this build. -->
      <id>ci</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <systemPropertyVariables>
                <org.apache.maven.user-settings>../../settings.xml</org.apache.maven.user-settings>
              </systemPropertyVariables>
              <redirectTestOutputToFile>${redirect.test.output}</redirectTestOutputToFile>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- allows dropping all databases -->
    <profile>
      <id>clean-db</id>
      <dependencies>
        <dependency>
          <groupId>org.finos.fluxnova.bpm</groupId>
          <artifactId>fluxnova-engine</artifactId>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack-sql-scripts</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.finos.fluxnova.bpm</groupId>
                      <artifactId>fluxnova-engine</artifactId>
                      <outputDirectory>${project.build.directory}/sql-scripts/engine</outputDirectory>
                      <overWrite>true</overWrite>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sql-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>drop-db-if-present</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <srcFiles>
                    <!-- try dropping the DB if it exists. -->
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.decision.engine.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.case.engine.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.engine.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.identity.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.decision.history.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.case.history.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.history.sql</srcFile>
                  </srcFiles>
                  <autocommit>true</autocommit>
                  <onError>continue</onError>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
