<?xml version='1.0' encoding='UTF-8'?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <modelVersion>4.0.0</modelVersion>

   <parent>
      <groupId>org.infinispan</groupId>
      <artifactId>infinispan-integrationtests-parent</artifactId>
      <version>11.0.0.Dev03</version>
      <relativePath>../pom.xml</relativePath>
   </parent>

   <artifactId>integrationtests-osgi</artifactId>
   <name>Integration tests - OSGi/Karaf</name>
   <packaging>bundle</packaging>
   <description>Integration tests for Infinispan running in OSGi/Karaf</description>

   <properties>
      <defaultTestGroup />
      <defaultExcludedTestGroup />
      <infinispan.test.parallel.threads>1</infinispan.test.parallel.threads>
      <forkJvmArgs>-Xmx500m -XX:HeapDumpPath=${user.dir}</forkJvmArgs>
      <target.tmp.dir>${project.build.directory}/tmp/</target.tmp.dir>
      <skipOSGiTests>${skipTests}</skipOSGiTests>
      <verbose.karaf>false</verbose.karaf>
   </properties>

   <dependencies>
      <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-slf4j-impl</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-commons</artifactId>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-core</artifactId>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-commons-test</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-core</artifactId>
         <type>test-jar</type>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-cachestore-jdbc</artifactId>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-cachestore-jdbc</artifactId>
         <type>test-jar</type>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-client-hotrod</artifactId>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-core</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-osgi</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>javax.persistence</groupId>
         <artifactId>javax.persistence-api</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-cachestore-jpa</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-cachestore-jpa</artifactId>
         <type>test-jar</type>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-cachestore-rocksdb</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-hibernate-cache-v53</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-server-hotrod</artifactId>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-server-hotrod</artifactId>
         <type>test-jar</type>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-cachestore-remote</artifactId>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-osgi</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>io.agroal</groupId>
         <artifactId>agroal-pool</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>com.h2database</groupId>
         <artifactId>h2</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-client-hotrod</artifactId>
         <type>test-jar</type>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-multimap</artifactId>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-clustered-lock</artifactId>
      </dependency>
      <dependency>
         <groupId>org.infinispan</groupId>
         <artifactId>infinispan-clustered-counter</artifactId>
      </dependency>
      <dependency>
         <groupId>javax.inject</groupId>
         <artifactId>javax.inject</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.ops4j.pax.exam</groupId>
         <artifactId>pax-exam-container-karaf</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.ops4j.pax.exam</groupId>
         <artifactId>pax-exam-junit4</artifactId>
         <scope>test</scope>
         <exclusions>
            <exclusion>
               <artifactId>bndlib</artifactId>
               <groupId>biz.aQute.bnd</groupId>
            </exclusion>
         </exclusions>
      </dependency>
      <dependency>
         <groupId>org.ops4j.pax.exam</groupId>
         <artifactId>pax-exam</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.ops4j.pax.exam</groupId>
         <artifactId>pax-exam-inject</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.ops4j.pax.url</groupId>
         <artifactId>pax-url-aether</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.ops4j.pax.url</groupId>
         <artifactId>pax-url-assembly</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.ops4j.pax.url</groupId>
         <artifactId>pax-url-wrap</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.apache.karaf.features</groupId>
         <artifactId>org.apache.karaf.features.core</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.testng</groupId>
         <artifactId>testng</artifactId>
         <scope>test</scope>
      </dependency>
      <!-- Uncomment to debug. Included in org.apache.karaf.features.core, but without sources -->
            <dependency>
               <groupId>org.apache.felix</groupId>
               <artifactId>org.apache.felix.resolver</artifactId>
               <version>1.16.0</version>
               <scope>test</scope>
            </dependency>
      <!-- Uncomment to debug surefire and the test container -->
      <!--<dependency>-->
         <!--<groupId>org.apache.maven.surefire</groupId>-->
         <!--<artifactId>surefire-api</artifactId>-->
         <!--<version>${version.maven.surefire}</version>-->
         <!--<scope>provided</scope>-->
      <!--</dependency>-->
      <!--<dependency>-->
         <!--<groupId>org.apache.maven.surefire</groupId>-->
         <!--<artifactId>maven-surefire-common</artifactId>-->
         <!--<version>${version.maven.surefire}</version>-->
         <!--<scope>provided</scope>-->
      <!--</dependency>-->
      <!--<dependency>-->
         <!--<groupId>org.apache.maven.surefire</groupId>-->
         <!--<artifactId>surefire-junit47</artifactId>-->
         <!--<version>${version.maven.surefire}</version>-->
         <!--<scope>provided</scope>-->
      <!--</dependency>-->
      <!--<dependency>-->
         <!--<groupId>org.ops4j.pax.exam</groupId>-->
         <!--<artifactId>pax-exam-invoker-junit</artifactId>-->
         <!--<version>${version.pax.exam}</version>-->
      <!--</dependency>-->
   </dependencies>

   <build>
      <testResources>
         <testResource>
            <directory>${project.basedir}/src/test/resources</directory>
            <filtering>true</filtering>
            <includes>
               <include>**/*</include>
            </includes>
         </testResource>
      </testResources>
      <plugins>
         <!-- IMPORTANT: generates META-INF/maven/dependencies.properties
              required by PAX-EXAM framework -->
         <plugin>
            <groupId>org.apache.servicemix.tooling</groupId>
            <artifactId>depends-maven-plugin</artifactId>
            <executions>
               <execution>
                  <id>generate-depends-file</id>
                  <goals>
                     <goal>generate-depends-file</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
               <execution>
                  <id>generate-tmp-dir</id>
                  <phase>generate-test-resources</phase>
                  <configuration>
                     <target>
                        <mkdir dir="${target.tmp.dir}" />
                     </target>
                  </configuration>
                  <goals>
                     <goal>run</goal>
                  </goals>
               </execution>
               <execution>
                  <id>stop-karaf-test-containers</id>
                  <phase>prepare-package</phase>
                  <configuration>
                     <target xmlns:if="ant:if">
                        <condition property="kill-argument-prefix" value="/PID ">
                           <os family="windows"/>
                        </condition>
                        <property name="kill-argument-prefix" value=" "/>
                        <loadfile property="karaf.pids">
                           <concat fixlastline="true">
                              <fileset dir="${project.build.directory}" includes="**/karaf.pid"/>
                              <filterchain>
                                 <filterreader classname="org.apache.tools.ant.filters.PrefixLines">
                                    <param name="prefix" value="${kill-argument-prefix}"/>
                                 </filterreader>
                                 <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks"/>
                              </filterchain>
                           </concat>
                        </loadfile>
                        <echo>Found Karaf pids: ${karaf.pids}</echo>
                        <exec osfamily="windows" executable="taskkill">
                           <arg line="/F /T ${karaf.pids}"/>
                        </exec>
                        <exec executable="kill" osfamily="unix">
                           <arg line="-9 ${karaf.pids}"/>
                        </exec>
                     </target>
                  </configuration>
                  <goals>
                     <goal>run</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
               <execution>
                  <id>default-test</id>
                  <phase>none</phase>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>

   <profiles>
      <profile>
         <id>smoke</id>
         <properties>
            <skipOSGiTests>true</skipOSGiTests>
         </properties>
      </profile>
      <profile>
         <id>java8-test</id>
         <build>
            <plugins>
               <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-surefire-plugin</artifactId>
                  <configuration>
                     <threadCount>1</threadCount>
                     <parallel>classes</parallel>
                     <groups combine.self="override"></groups>
                     <excludedGroups combine.self="override"></excludedGroups>
                     <systemPropertyVariables>
                        <java.io.tmpdir>${target.tmp.dir}</java.io.tmpdir>
                        <verbose.karaf>${verbose.karaf}</verbose.karaf>
                        <infinispan.test.checkThreadLeaks>false</infinispan.test.checkThreadLeaks>
                     </systemPropertyVariables>
                     <runOrder>alphabetical</runOrder>
                     <skipTests>${skipOSGiTests}</skipTests>
                     <failIfNoTests>false</failIfNoTests>
                     <testNGArtifactName>none:none</testNGArtifactName>
                     <disableXmlReport>false</disableXmlReport>
                     <runOrder>alphabetical</runOrder>
                     <properties>
                        <usedefaultlisteners>false</usedefaultlisteners>
                        <listener>${junitListener}</listener>
                     </properties>
                  </configuration>
                  <dependencies>
                     <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>${version.maven.surefire}</version>
                     </dependency>
                  </dependencies>
                  <executions>
                     <!--
                     Make sure two containers are not started at the same time by separating the
                     PerSuite reactor tests from PerClass/PerMethod(default).

                     Note: @Category(PerSuite.class) needs to be specified in addition to the
                     @PaxExamReactor(PerSuite.class) annotation.
                     -->
                     <execution>
                        <id>java8-test</id>
                        <phase>test</phase>
                        <goals>
                           <goal>test</goal>
                        </goals>
                        <configuration>
                           <!-- Include the tests that can reuse a single Karaf container -->
                           <groups>org.ops4j.pax.exam.spi.reactors.PerSuite</groups>
                           <jvm>${env.JAVA8_HOME}/bin/java</jvm>
                           <argLine>${forkJvmArgs}</argLine>
                        </configuration>
                     </execution>
                     <execution>
                        <id>java8-test-new-container</id>
                        <phase>test</phase>
                        <goals>
                           <goal>test</goal>
                        </goals>
                        <configuration>
                           <!-- Include the tests that need a separate container for each test/method -->
                           <groups>org.ops4j.pax.exam.spi.reactors.PerClass,org.ops4j.pax.exam.spi.reactors.PerMethod</groups>
                           <excludedGroups>org.ops4j.pax.exam.spi.reactors.PerSuite</excludedGroups>
                           <jvm>${env.JAVA8_HOME}/bin/java</jvm>
                           <argLine>${forkJvmArgs}</argLine>
                        </configuration>
                     </execution>
                  </executions>
               </plugin>
            </plugins>
         </build>
      </profile>
   </profiles>
</project>

