<!--
 -
 - Licensed to the Apache Software Foundation (ASF) under one
 - or more contributor license agreements.  See the NOTICE file
 - distributed with this work for additional information
 - regarding copyright ownership.  The ASF licenses this file
 - to you under the Apache License, Version 2.0 (the
 - "License"); you may not use this file except in compliance
 - with the License.  You may obtain a copy of the License at
 -
 -   http://www.apache.org/licenses/LICENSE-2.0
 -
 - Unless required by applicable law or agreed to in writing,
 - software distributed under the License is distributed on an
 - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 - KIND, either express or implied.  See the License for the
 - specific language governing permissions and limitations
 - under the License.
 -
 -->
<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>proton-tests</artifactId>
  <name>proton-tests</name>

  <description>The Proton system tests execute against either the Java or the C implementations,
based on the chosen profile.

To execute, run either "mvn test" or "mvn test -P proton-jni".

Example of advanced usage (all of the -D flags are optional):

mvn test \
-P proton-jni \
-Dproton.pythontest.pattern='proton_tests.transport.TransportTest.*' \
-Dproton.pythontest.invocations=20 \
-Dproton.pythontest.always_colorize=true \
-Dproton-c-build-dir=/path/to/build/dir

By default, the proton-jni profile looks for the JNI jar and native libraries under
directory &lt;basedir&gt;/build/proton-c.</description>

  <properties>
    <testReportOutputDirectory>${basedir}/target/surefire-reports</testReportOutputDirectory>
  </properties>

  <build>
    <!-- System tests are arranged by language, hence the non-default location of the JUnit tests. -->
    <testSourceDirectory>java</testSourceDirectory>
    <resources>
      <resource><directory>resources</directory></resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemPropertyVariables>
            <protonJythonIgnoreFile>${basedir}/java/pythonTests.ignore</protonJythonIgnoreFile>
            <protonJythonTestRoot>${basedir}/python</protonJythonTestRoot>
            <protonJythonTestScript>${basedir}/python/proton-test</protonJythonTestScript>
            <protonJythonTestXmlOutputDirectory>${testReportOutputDirectory}</protonJythonTestXmlOutputDirectory>
            <java.util.logging.config.file>${project.build.outputDirectory}/logging.properties</java.util.logging.config.file>
          </systemPropertyVariables>
         <reportsDirectory>${testReportOutputDirectory}</reportsDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit-version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.qpid</groupId>
      <artifactId>proton-api</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>org.python</groupId>
        <artifactId>jython-standalone</artifactId>
        <version>2.5.3</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <!-- proton-j-impl is even required for profile proton-jni so we can use EncoderImpl and DecoderImpl to
           generate test data, hence this dependency appearing here and not just in the proton-j profile -->
      <groupId>org.apache.qpid</groupId>
      <artifactId>proton-j-impl</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <!-- Depend on test helper classes contained with test-jar from proton-j-impl -->
      <groupId>org.apache.qpid</groupId>
      <artifactId>proton-j-impl</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
      <type>test-jar</type>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>proton-j</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <systemPropertyVariables>
                <qpid.proton.implementationtype>PROTON_J</qpid.proton.implementationtype>
              </systemPropertyVariables>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>proton-jni</id>
      <properties>
        <!-- Uses the JNI jar and the native libraries, neither of which are built by Maven,
             therefore their location needs to be set explicitly in the following properties. -->
        <proton-c-build-dir>${basedir}/../build/proton-c</proton-c-build-dir>
        <jni-native-path>${proton-c-build-dir}:${proton-c-build-dir}/bindings/java</jni-native-path>
        <jni-jar>${proton-c-build-dir}/bindings/java/proton-jni.jar</jni-jar>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <forkMode>once</forkMode>
              <argLine>-Djava.library.path=${jni-native-path}</argLine>
              <systemPropertyVariables>
                <qpid.proton.implementationtype>PROTON_C</qpid.proton.implementationtype>
              </systemPropertyVariables>
            </configuration>
          </plugin>
        </plugins>
      </build>
      <dependencies>
        <dependency>
          <groupId>org.apache.qpid</groupId>
          <artifactId>proton-jni</artifactId>
          <version>${project.parent.version}</version>
          <scope>system</scope>
          <systemPath>${jni-jar}</systemPath>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

  <parent>
    <groupId>org.apache.qpid</groupId>
    <artifactId>proton-project</artifactId>
    <version>0.6.redhat-003</version>
  </parent>
  <scm>
    <url>http://svn.apache.org/viewvc/qpid/proton/</url>
    <tag>proton-project-0.6.redhat-003</tag>
  </scm>
</project>
