<?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: pom.xml 20565 2010-11-08 11:38:20Z benoitf $
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<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-M3</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.ow2.jonas</groupId>
  <artifactId>jonas-itests-cargo-security</artifactId>
  <name>JOnAS :: iTests :: Cargo :: JMX security</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/java/org/ow2/jonas/itests/cargo/jrmp" />
                <copy todir="src/test/java/org/ow2/jonas/itests/cargo/jrmp">
                  <fileset dir="../jrmp/src/test/java/org/ow2/jonas/itests/cargo/jrmp" />
                </copy>
                <replace dir="src/test/java/org/ow2/jonas/itests/cargo/jrmp" token=".cargo.jrmp" value=".cargo.jmx_security">
                  <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="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>


                <replace file="${jonas.base}/conf/jonas.properties">
                    <replacetoken><![CDATA[jonas.services    ]]></replacetoken>
                    <replacevalue><![CDATA[jonas.services    security,]]></replacevalue>
                </replace>
                <replace file="${jonas.base}/conf/jonas.properties">
                    <replacetoken><![CDATA[jonas.service.jmx.secured                       false]]></replacetoken>
                    <replacevalue><![CDATA[jonas.service.jmx.secured                       true]]></replacevalue>
                </replace>
                <replace file="${jonas.base}/conf/jonas.properties">
                    <replacetoken><![CDATA[jonas.service.jmx.authentication.method         jmx.remote.x.password.file]]></replacetoken>
                    <replacevalue><![CDATA[jonas.service.jmx.authentication.method         jmx.remote.x.login.config]]></replacevalue>
                </replace>
                <replace file="${jonas.base}/conf/jonas.properties">
                    <replacetoken><![CDATA[jonas.service.jmx.authentication.parameter      conf/jmx.passwords]]></replacetoken>
                    <replacevalue><![CDATA[jonas.service.jmx.authentication.parameter      jaas-jmx]]></replacevalue>
                </replace>
                <replace file="${jonas.base}/conf/jonas.properties">
                    <replacetoken><![CDATA[jonas.service.jmx.authorization.method          jmx.remote.x.access.file]]></replacetoken>
                    <replacevalue><![CDATA[jonas.service.jmx.authorization.method          jmx.remote.x.access.rolebased.file]]></replacevalue>
                </replace>
                <replace file="${jonas.base}/conf/jonas.properties">
                    <replacetoken><![CDATA[jonas.service.jmx.authorization.parameter       conf/jmx.access]]></replacetoken>
                    <replacevalue><![CDATA[jonas.service.jmx.authorization.parameter       conf/jmx.rolebased.access]]></replacevalue>
                </replace>



                <!-- 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>
              <cargo.remote.username>jonas</cargo.remote.username>
              <cargo.remote.password>jonas</cargo.remote.password>
            </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}/jrmpconnector_jonas</value>
                </property>
                <property>
                  <name>project.version</name>
                  <value>${project.version}</value>
                </property>
              </systemProperties>
              <skip>false</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
