<?xml version="1.0" encoding="UTF-8"?>
<!--
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  - JOnAS: Java(TM) Open Application Server
  - Copyright (C) 2007-2009 Bull S.A.S.
  - Contact: jonas-team@objectweb.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-cargo</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-cargo-irmi</artifactId>
  <name>JOnAS :: iTests :: Cargo :: IRMI</name>
  <description>Tests the JOnAS distribution via CARGO</description>

  <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>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                </artifactItem>
              </artifactItems>
              <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>copy-tests</id>
            <phase>generate-test-sources</phase>
            <configuration>
              <tasks>
                <delete dir="src/test" />
                <copy todir="src/test">
                  <fileset dir="../jrmp/src/test" />
                </copy>
                <replace dir="src/test/java" token=".cargo.jrmp" value=".cargo.irmi">
                  <include name="**/*.java" />
                </replace>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
          <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 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="irmi" />
                  <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>

                <!-- We'll be using a versioned ctxroot for tests -->
                <delete file="${jonas.base}/deploy/ctxroot.xml" />
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Start and stop JOnAS with CARGO -->
      <plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven2-plugin</artifactId>
        <version>${cargo.version}</version>
        <executions>
          <execution>
            <id>start-jonas</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>start</goal>
            </goals>
          </execution>
          <execution>
            <id>stop-jonas</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <wait>false</wait>
          <container>
            <containerId>jonas5x</containerId>
            <type>installed</type>
            <home>${jonas.root}</home>
          </container>
          <configuration>
            <type>existing</type>
            <home>${jonas.base}</home>
            <properties>
              <cargo.hostname>localhost</cargo.hostname>
              <cargo.servlet.port>${webcontainer.port}</cargo.servlet.port>
              <cargo.protocol>http</cargo.protocol>
            </properties>
            <deployables>
              <deployable>
                <groupId>org.ow2.jonas</groupId>
                <artifactId>jonas-itests-applications-connection-leaks</artifactId>
                <type>war</type>
              </deployable>
              <deployable>
                <groupId>org.ow2.jonas</groupId>
                <artifactId>jonas-itests-applications-jaxws-sample</artifactId>
                <type>ear</type>
              </deployable>
              <deployable>
                <groupId>org.ow2.jonas.jonas-itests-applications-jaxws-add.assemblies</groupId>
                <artifactId>wsadd</artifactId>
                <type>ear</type>
              </deployable>
            </deployables>
          </configuration>
        </configuration>
      </plugin>

      <!-- Run integration tests -->
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
        <executions>
          <execution>
            <id>surefire-it</id>
            <phase>integration-test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemProperties>
                <property>
                  <name>webcontainer.port</name>
                  <value>${webcontainer.port}</value>
                </property>
                <property>
                  <name>carol.url</name>
                  <value>service:jmx:rmi://localhost/jndi/rmi://localhost:${carol.port}/irmiconnector_jonas</value>
                </property>
                <property>
                  <name>project.version</name>
                  <value>${project.version}</value>
                </property>
              </systemProperties>
              <skip>false</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
