<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.kie</groupId>
    <artifactId>kie-server-parent</artifactId>
    <version>6.2.0.Final</version>
  </parent>

  <artifactId>kie-server-tests</artifactId>
  <packaging>pom</packaging>

  <name>KIE :: Execution Server :: Tests Parent</name>
  <description>KIE Execution Server Tests Parent</description>

  <!-- Properties shared between the different test modules -->
  <properties>
    <!-- This property needs to be overridden when running tests against different version of the WAR (e.g. running
             SNAPSHOT tests against Beta3 WAR) so the tests actually know what exact version of server is being tested -->
    <kie.server.version>${project.version}</kie.server.version>
    <!-- Following properties are used only for testing -->
    <container.hostname>localhost</container.hostname>
    <!-- <container.port/> can't define the default port value, because the build-helper-maven-plugin:reserve-network-port
         is not able to override the value of the property. The port number would then always be the same
         (the default one, unless changed from outside) -->
    <kie.server.context>kie-server-services</kie.server.context>
    <kie.server.base.uri>http://${container.hostname}:${container.port}/${kie.server.context}/services/rest/server</kie.server.base.uri>
    <kie.server.testing.server.local.repo.dir>${project.build.directory}/kie-server-testing-server-local-repo</kie.server.testing.server.local.repo.dir>
    <kie.server.testing.remote.repo.dir>${project.build.directory}/kie-server-testing-remote-repo</kie.server.testing.remote.repo.dir>
    <!-- This property can be overriden when some other remote repo location should be used -->
    <kie.server.testing.remote.repo.url>file://${kie.server.testing.remote.repo.dir}</kie.server.testing.remote.repo.url>

    <tomcat7x.download.url>https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.55/bin/apache-tomcat-7.0.55.zip</tomcat7x.download.url>
    <tomcat8x.download.url>https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.12/bin/apache-tomcat-8.0.12.zip</tomcat8x.download.url>
    <jbossas71x.download.url>http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip</jbossas71x.download.url>
    <wildfly81x.download.url>http://download.jboss.org/wildfly/8.1.0.Final/wildfly-8.1.0.Final.zip</wildfly81x.download.url>
    <wildfly82x.download.url>http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.zip</wildfly82x.download.url>
    <!-- The EAP 6.4.x binary can't be anonymously downloaded due to license issues. It can be downloaded manually
         and for free (e.g. from http://jbossas.jboss.org/downloads.html) and the zip location needs to be specified
         here or via system property when running the build (don't forget to use the `file://` prefix when
         referencing the zip from local filesystem). -->
    <eap64x.download.url>valid-url-for-eap-6.4.x-needs-to-be-specified-here-or-via-cmd-line</eap64x.download.url>
  </properties>

  <modules>
    <module>kie-server-rest-tests</module>
    <module>kie-server-jms-tests</module>
  </modules>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.cargo</groupId>
          <artifactId>cargo-maven2-plugin</artifactId>
          <configuration>
            <container>
              <systemProperties>
                <kie.maven.settings.custom>${project.build.testOutputDirectory}/kie-server-testing-server-custom-settings.xml</kie.maven.settings.custom>
              </systemProperties>
            </container>
            <deployables>
              <deployable>
                <groupId>${project.groupId}</groupId>
                <artifactId>kie-server</artifactId>
                <!-- default, may be overriden in container specific profiles -->
                <classifier>ee6</classifier>
                <type>war</type>
                <properties>
                  <context>${kie.server.context}</context>
                </properties>
                <pingURL>${kie.server.base.uri}</pingURL>
                <pingTimeout>30000</pingTimeout>
              </deployable>
            </deployables>
            <configuration>
              <properties>
                <cargo.servlet.port>${container.port}</cargo.servlet.port>
                <!-- kie-server role for REST tests; guest for JMS tests -->
                <cargo.servlet.users>yoda:usetheforce123@:kie-server,guest</cargo.servlet.users>
              </properties>
            </configuration>
          </configuration>
          <executions>
            <execution>
              <id>start-container</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>start</goal>
              </goals>
            </execution>
            <execution>
              <id>stop-container</id>
              <phase>post-integration-test</phase>
              <goals>
                <goal>stop</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <executions>
            <execution>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>reserve-network-port</id>
            <goals>
              <goal>reserve-network-port</goal>
            </goals>
            <phase>pre-integration-test</phase>
            <configuration>
              <portNames>
                <portName>container.port</portName>
              </portNames>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>create-custom-maven-repo-dir</id>
            <phase>pre-integration-test</phase>
            <configuration>
              <tasks>
                <mkdir dir="${kie.server.testing.server.local.repo.dir}"/>
                <mkdir dir="${kie.server.testing.remote.repo.dir}"/>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>wildfly81x</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <configuration>
                <container>
                  <containerId>wildfly8x</containerId>
                  <type>installed</type>
                  <zipUrlInstaller>
                    <url>${wildfly81x.download.url}</url>
                  </zipUrlInstaller>
                </container>
                <configuration>
                  <properties>
                    <cargo.jboss.configuration>standalone-full</cargo.jboss.configuration>
                  </properties>
                </configuration>
                <deployables>
                  <deployable>
                    <classifier>ee7</classifier>
                  </deployable>
                </deployables>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <profile>
      <id>wildfly82x</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <configuration>
                <container>
                  <containerId>wildfly8x</containerId>
                  <type>installed</type>
                  <zipUrlInstaller>
                    <url>${wildfly82x.download.url}</url>
                  </zipUrlInstaller>
                </container>
                <configuration>
                  <properties>
                    <cargo.jboss.configuration>standalone-full</cargo.jboss.configuration>
                  </properties>
                </configuration>
                <deployables>
                  <deployable>
                    <classifier>ee7</classifier>
                  </deployable>
                </deployables>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <profile>
      <id>tomcat7x</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <configuration>
                <container>
                  <containerId>tomcat7x</containerId>
                  <type>installed</type>
                  <zipUrlInstaller>
                    <url>${tomcat7x.download.url}</url>
                  </zipUrlInstaller>
                </container>
                <deployables>
                  <deployable>
                    <classifier>webc</classifier>
                  </deployable>
                </deployables>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <profile>
      <id>tomcat8x</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <configuration>
                <container>
                  <containerId>tomcat8x</containerId>
                  <type>installed</type>
                  <zipUrlInstaller>
                    <url>${tomcat8x.download.url}</url>
                  </zipUrlInstaller>
                </container>
                <deployables>
                  <deployable>
                    <classifier>webc</classifier>
                  </deployable>
                </deployables>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <profile>
      <id>jbossas71x</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <configuration>
                <container>
                  <containerId>jboss71x</containerId>
                  <type>installed</type>
                  <zipUrlInstaller>
                    <url>${jbossas71x.download.url}</url>
                  </zipUrlInstaller>
                </container>
                <configuration>
                  <properties>
                    <cargo.jboss.configuration>standalone-full</cargo.jboss.configuration>
                  </properties>
                </configuration>
                <deployables>
                  <deployable>
                    <classifier>ee6</classifier>
                  </deployable>
                </deployables>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <profile>
      <id>eap64x</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <configuration>
                <container>
                  <!-- jboss74x works for now, but should be updated to jboss75x once Cargo supports EAP 6.4 -->
                  <containerId>jboss74x</containerId>
                  <type>installed</type>
                  <zipUrlInstaller>
                    <url>${eap64x.download.url}</url>
                  </zipUrlInstaller>
                </container>
                <configuration>
                  <properties>
                    <cargo.jboss.configuration>standalone-full</cargo.jboss.configuration>
                  </properties>
                </configuration>
                <deployables>
                  <deployable>
                    <classifier>ee6</classifier>
                  </deployable>
                </deployables>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <!-- This profile basically disables any cargo related execution. It can be used when the tests should run on
         a container that has already been started and it is not managed by cargo. It can also be used when doing
         a "no-test" build, as the container should not be used in that case. -->
    <profile>
      <id>custom-container</id>
      <activation>
        <!-- The tests are not executed unless specific container profile is used. Disable cargo by default. -->
        <activeByDefault>true</activeByDefault>
        <property>
          <name>custom-container</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <executions>
              <execution>
                <id>start-container</id>
                <phase>none</phase>
                <goals/>
                <!-- do nothing, container is not managed by cargo -->
              </execution>
              <execution>
                <id>stop-container</id>
                <phase>none</phase>
                <goals/>
                <!-- do nothing, container is not managed by cargo -->
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <!-- Integration tests are skipped by default. They are activated when specific container profile is used. -->
      <id>skipITs-by-default</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <artifactId>maven-failsafe-plugin</artifactId>
              <configuration>
                <skipITs>true</skipITs>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>
</project>
