<?xml version="1.0" encoding="UTF-8"?>
<!--
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  - JOnAS: Java(TM) Open Application Server
  - Copyright (C) 2009 Bull S.A.S.
  - Contact: jonas-team@ow2.org
  -
  - This library is free software; you can redistribute it and/or
  - modify it under the terms of the GNU Lesser General Public
  - License as published by the Free Software Foundation; either
  - version 2.1 of the License, or any later version.
  -
  - This library is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  - Lesser General Public License for more details.
  -
  - You should have received a copy of the GNU Lesser General Public
  - License along with this library; if not, write to the Free Software
  - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  - USA
  -
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  - $Id$
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<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/maven-v4_0_0.xsd">
  <parent>
    <groupId>org.ow2.jonas</groupId>
    <artifactId>jonas-itests</artifactId>
    <version>5.2.0-M2-SR1</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.ow2.jonas</groupId>
  <artifactId>jonas-itests-intravm</artifactId>
  <packaging>jar</packaging>
  <name>JOnAS :: iTests :: Intra VM</name>
  <description>Allows to run OSGi tests on the server side</description>

  <dependencies>
    <!-- Use the common tests here -->
    <dependency>
      <groupId>org.ow2.jonas.launchers</groupId>
      <artifactId>felix-launcher</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>org.ow2.jonas</groupId>
          <artifactId>jonas-commons</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    
    <!-- JOnAS services API -->
    <dependency>
      <groupId>org.ow2.jonas</groupId>
      <artifactId>jonas-services-api</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- Log -->
    <dependency>
      <groupId>org.ow2.bundles</groupId>
      <artifactId>ow2-util-log</artifactId>
      <scope>test</scope>
    </dependency>


    <!-- File Utils -->
    <dependency>
      <groupId>org.ow2.bundles</groupId>
      <artifactId>ow2-util-file</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- URL Utils -->
    <dependency>
      <groupId>org.ow2.bundles</groupId>
      <artifactId>ow2-util-url</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>servlet-api</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Testing Framework -->
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>5.11</version>
      <classifier>jdk15</classifier>
      <scope>test</scope>
    </dependency>


    <!-- Allows to create Bundle -->
    <dependency>
      <groupId>org.ops4j.pax.swissbox</groupId>
      <artifactId>pax-swissbox-tinybundles</artifactId>
      <version>1.2.0</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>

      <!--
        Make sure tests always use randomly assigned and available ports
      -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>${build-helper.version}</version>
        <executions>
          <execution>
            <id>generate-port-numbers</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>reserve-network-port</goal>
            </goals>
            <configuration>
              <portNames>
                <portName>webcontainer.port</portName>
                <portName>carol.port</portName>
                <portName>jms.port</portName>
                <portName>db.port</portName>
              </portNames>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Unpack the JOnAS assembly -->
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-assembly</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.ow2.jonas.assemblies.profiles</groupId>
                  <artifactId>jonas-full</artifactId>
                  <version>${project.version}</version>
                  <classifier>bin</classifier>
                  <type>zip</type>
                </artifactItem>
              </artifactItems>
              <outputDirectory>
                ${project.build.directory}
              </outputDirectory>
              <overWriteReleases>true</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Configure JOnAS services and their port numbers -->
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>create-jonas-base-with-all-options</id>
            <phase>generate-test-resources</phase>
            <configuration>
              <tasks>
                <delete dir="${jonas.base}" />
                <mkdir dir="${jonas.base}/deploy" />

                <typedef resource="org/ow2/jonas/ant/antlib.xml" classpath="${jonas.root}/lib/common/ow_jonas_ant.jar" />

                <jonasbase jonasRoot="${jonas.root}" destDir="${jonas.base}" update="off">
                  <jonasProperties workDirectory="work-tests" services="${jonas.services}" />
                  <webcontainer>
                    <tomcat>
                      <http port="${webcontainer.port}" />
                    </tomcat>
                    <jetty>
                      <http port="${webcontainer.port}" />
                    </jetty>
                  </webcontainer>
                  <jms port="${jms.port}" initialTopics="" initialQueues="" />
                  <carol defaultPort="${carol.port}" protocols="jrmp" />
                  <db port="${db.port}" />
                  <jdbcRa name="jdbc_1" mapperName="rdb.hsql" user="jonas" password="jonas" url="jdbc:hsqldb:hsql://localhost:${db.port}/db_jonas" driverName="org.hsqldb.jdbcDriver" jndiName="jdbc_1" autoload="on" />
                </jonasbase>

                <!-- Add servlet packages to the System Bundle so that the tests and the
                     web container classes agree on the API -->
                <replace file="${jonas.base}/conf/osgi/gateway.properties">
                  <replacetoken><![CDATA[org.osgi.framework.system.packages.extra]]></replacetoken>
                  <replacevalue><![CDATA[org.osgi.framework.system.packages.extra javax.servlet; version=2.5.0, javax.servlet.http; version=2.5.0]]></replacevalue>
                </replace>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>


      <!-- Launch the tests -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <forkMode>once</forkMode>
          <parallel>classes</parallel>
          <threadCount>10</threadCount>
          <additionalClasspathElements>
            <additionalClasspathElement>${jonas.base}/conf</additionalClasspathElement>
          </additionalClasspathElements>
          <systemProperties>
            <property>
              <name>jonas.root</name>
              <value>${jonas.root}</value>
            </property>
            <property>
              <name>jonas.base</name>
              <value>${jonas.base}</value>
            </property>
            <property>
              <name>ipojo.log.level</name>
              <value>ERROR</value>
            </property>
            <property>
              <name>java.security.policy</name>
              <value>${jonas.base}/conf/java.policy</value>
            </property>
            <property>
              <name>java.security.auth.login.config</name>
              <value>${jonas.base}/conf/jaas.config</value>
            </property>
            <property>
              <name>java.endorsed.dirs</name>
              <value>${jonas.root}/lib/endorsed</value>
            </property>
            <property>
              <name>jonas.felix.configuration.file</name>
              <value>${jonas.base}/conf/felix-config.properties</value>
            </property>
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
