<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>

  <parent>
    <groupId>org.eximeebpms.bpm.qa</groupId>
    <artifactId>eximeebpms-qa</artifactId>
    <version>1.1.2</version>
  </parent>

  <artifactId>eximeebpms-qa-old-engine</artifactId>
  <packaging>jar</packaging>
  <name>EximeeBPMS - QA - test new schema with old engine</name>

  <properties>
    <eximeebpms.old.engine.version>1.0.0</eximeebpms.old.engine.version>
  </properties>

  <build>
    <testSourceDirectory>${project.build.directory}/engine-test-sources</testSourceDirectory>
    <testResources>
      <testResource>
        <directory>${project.build.directory}/engine-test-sources</directory>
        <excludes>
          <exclude>**/*.java</exclude>
          <exclude>eximeebpms.cfg.xml</exclude>
          <exclude>**/historycleanup.eximeebpms.cfg.xml</exclude>
        </excludes>
      </testResource>
      <testResource>
        <directory>config</directory>
        <filtering>true</filtering>
      </testResource>
    </testResources>
  </build>

  <profiles>
    <profile>
      <id>distro</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skipTests>true</skipTests>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>mysql</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <failIfNoTests>false</failIfNoTests>
              <trimStackTrace>false</trimStackTrace>
              <redirectTestOutputToFile>true</redirectTestOutputToFile>
              <excludes combine.children="append">
                <exclude>**/CompetingMessageCorrelationTest.java</exclude>
              </excludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>old-engine</id>

      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>org.camunda.bpm</groupId>
            <artifactId>camunda-bom</artifactId>
            <!-- Cannot use variables due to bug in Maven Release Plugin -->
            <version>7.23.0</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>jakarta.platform</groupId>
            <artifactId>jakarta.jakartaee-bom</artifactId>
            <version>${version.jakarta-ee-spec}</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>
        </dependencies>
      </dependencyManagement>

      <dependencies>
       <dependency>
          <groupId>com.fasterxml.uuid</groupId>
          <artifactId>java-uuid-generator</artifactId>
          <scope>test</scope>
        </dependency>

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

        <dependency>
          <groupId>org.hamcrest</groupId>
          <artifactId>hamcrest-library</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-test</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>com.h2database</groupId>
          <artifactId>h2</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>commons-collections</groupId>
          <artifactId>commons-collections</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-email</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>org.subethamail</groupId>
          <artifactId>subethasmtp-wiser</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>commons-io</groupId>
          <artifactId>commons-io</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>org.apache.groovy</groupId>
          <artifactId>groovy-jsr223</artifactId>
        </dependency>

        <dependency>
          <groupId>org.python</groupId>
          <artifactId>jython</artifactId>
          <scope>runtime</scope>
        </dependency>

        <dependency>
          <groupId>org.jruby</groupId>
          <artifactId>jruby-complete</artifactId>
          <scope>runtime</scope>
        </dependency>

        <dependency>
          <groupId>org.eximeebpms.bpm.distro</groupId>
          <artifactId>eximeebpms-sql-scripts</artifactId>
          <version>${project.version}</version>
          <type>test-jar</type>
        </dependency>

        <dependency>
          <groupId>org.eximeebpms.bpm</groupId>
          <artifactId>eximeebpms-engine</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.mockito</groupId>
          <artifactId>mockito-core</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-lang3</artifactId>
          <version>${version.commons-lang3}</version>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>org.assertj</groupId>
          <artifactId>assertj-core</artifactId>
          <version>2.9.1</version>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>org.eximeebpms.commons</groupId>
          <artifactId>eximeebpms-commons-testing</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>com.github.tomakehurst</groupId>
          <artifactId>wiremock</artifactId>
          <scope>test</scope>
          <exclusions>
            <exclusion>
              <groupId>org.apache.commons</groupId>
              <artifactId>commons-lang3</artifactId>
            </exclusion>
            <exclusion>
              <groupId>com.jayway.jsonpath</groupId>
              <artifactId>json-path</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
        
        <dependency>
          <groupId>org.graalvm.js</groupId>
          <artifactId>js</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>org.graalvm.js</groupId>
          <artifactId>js-scriptengine</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>jakarta.transaction</groupId>
          <artifactId>jakarta.transaction-api</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>org.apache.geronimo.specs</groupId>
          <artifactId>geronimo-jta_1.1_spec</artifactId>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>com.github.h-thurow</groupId>
          <artifactId>simple-jndi</artifactId>
          <version>0.25.0</version>
          <scope>test</scope>
          <exclusions>
            <exclusion>
              <groupId>commons-lang</groupId>
              <artifactId>commons-lang</artifactId>
            </exclusion>
            <exclusion>
              <artifactId>commons-lang3</artifactId>
              <groupId>org.apache.commons</groupId>
            </exclusion>
          </exclusions>
        </dependency>

        <dependency>
          <groupId>org.jboss</groupId>
          <artifactId>jboss-vfs</artifactId>
          <version>3.1.0.Final</version>
          <scope>test</scope>
        </dependency>
      </dependencies>

      <build>
        <plugins>

          <!--UNPACKING-->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>

            <executions>
              <!--UNPACK OLD TEST SUITE-->
              <execution>
                <id>unpack-engine-tests</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.eximeebpms.bpm</groupId>
                      <artifactId>eximeebpms-engine</artifactId>
                      <version>${eximeebpms.old.engine.version}</version>
                      <type>test-jar</type>
                      <outputDirectory>${project.build.directory}/test-classes</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>

              <!--UNPACK NEW SQL SCRIPTS-->
              <execution>
                <id>unpack-new-scripts</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.eximeebpms.bpm.distro</groupId>
                      <artifactId>eximeebpms-sql-scripts</artifactId>
                      <version>${project.version}</version>
                      <type>test-jar</type>
                      <outputDirectory>${project.build.directory}/scripts-current</outputDirectory>
                      <overWrite>true</overWrite>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>

          </plugin>

          <!--SQL EXECUTION-->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sql-maven-plugin</artifactId>
            <executions>

              <!--DROP DB IF PRESENT-->
              <execution>
                <id>drop-db-if-present</id>
                <phase>generate-test-resources</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <srcFiles>
                    <srcFile>${project.build.directory}/scripts-current/sql/drop/${database.type}_engine_${project.version}.sql</srcFile>
                    <srcFile>${project.build.directory}/scripts-current/sql/drop/${database.type}_identity_${project.version}.sql</srcFile>
                  </srcFiles>
                  <autocommit>true</autocommit>
                  <onError>continue</onError>
                </configuration>
              </execution>

              <!--CREATE NEW SCHEMA-->
              <execution>
                <id>create-new-schema</id>
                <phase>generate-test-resources</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <srcFiles>
                    <srcFile>${project.build.directory}/scripts-current/sql/create/${database.type}_engine_${project.version}.sql</srcFile>
                    <srcFile>${project.build.directory}/scripts-current/sql/create/${database.type}_identity_${project.version}.sql</srcFile>
                  </srcFiles>
                </configuration>
              </execution>

              <!--DROP DB AFTER TEST-->
              <execution>
                <id>drop-db</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <srcFiles>
                    <srcFile>${project.build.directory}/scripts-current/sql/drop/${database.type}_engine_${project.version}.sql</srcFile>
                    <srcFile>${project.build.directory}/scripts-current/sql/drop/${database.type}_identity_${project.version}.sql</srcFile>
                  </srcFiles>
                </configuration>
              </execution>

            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludes>
                <exclude>**/*TestCase.java</exclude>

                <exclude>**/ClassPathScannerTest.java</exclude>
                <exclude>**/MultipleClasspathRootsClassPathScannerTest.java</exclude>

                <exclude>**/WSDLImporterTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-315 -->
                <exclude>**/JobExecutorTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-427 -->
                <exclude>**/HistoricTaskInstanceUpdateTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-485 -->
                <exclude>**/RepeatingServiceTaskTest.java</exclude>
                <!--Exclude test class, because 4 tests fail and are removed on later patch versions -->
                <exclude>**/MultiTenancyHistoricProcessInstanceReportCmdTenantCheckTest.java</exclude>

                <!-- commons-email 1.5 update -->
                <exclude>**/AsyncEmailTaskTest.java</exclude>
                <exclude>**/EmailSendTaskTest.java</exclude>
                <exclude>**/EmailServiceTaskTest.java</exclude>

                <!-- Exclude test classes because resources are not available in the old-engine classpath -->
                <exclude>**/ProcessDiagramRetrievalTest.java</exclude>
                <exclude>**/ProcessDiagramParseTest.java</exclude>
                <exclude>**/ConnectionPersistenceExceptionTest.java</exclude>

                <!-- Exclude test class because old-engine tests old engine version with new db schema version -->
                <exclude>**/SchemaLogEnsureSqlScriptTest.java</exclude>

                <exclude>**/ManagementServiceTableCountTest.java</exclude>

                <!-- The test is not relevant in `old-engine` setup since the feature has been removed -->
                <!-- See https://github.com/camunda/camunda-bpm-platform/pull/4544#discussion_r1728748399 -->
                <exclude>**/ConcurrentTelemetryConfigurationTest.java</exclude>

                <!-- The test is not relevant in `old-engine` setup and lacks necessary resource files -->
                <exclude>**DatabaseNamingConsistencyTest.java</exclude>
              </excludes>
              <testFailureIgnore>false</testFailureIgnore>
              <redirectTestOutputToFile>true</redirectTestOutputToFile>
              <argLine>-Xmx2g -Duser.language=en -Duser.region=US -XX:+HeapDumpOnOutOfMemoryError
                -XX:HeapDumpPath=${project.build.directory}/heap_dump.hprof
                --add-opens=java.base/java.util=ALL-UNNAMED
                --add-opens=java.base/java.lang=ALL-UNNAMED</argLine>
            </configuration>
          </plugin>

        </plugins>
      </build>
    </profile>

    <profile>
     <id>exclude-post-jdk15-tests</id>
      <activation>
        <jdk>[15,)</jdk>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <artifactId>maven-surefire-plugin</artifactId>
              <configuration>
                <!-- Nashorn is not part of the JDK anymore in Java 15+ -->
                <excludes combine.children="append">
                  <exclude>**/*NashornTest.java</exclude>
                </excludes>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

  </profiles>

</project>
