<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, a division of Red Hat
  ~ Copyright 2011, Red Hat Middleware, LLC, and individual
  ~ contributors as indicated by the @authors tag. See the
  ~ copyright.txt in the distribution for a full listing of
  ~ individual contributors.
  ~
  ~ This 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 (at your option) any later version.
  ~
  ~ This software 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 software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->

<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">
   <parent>
      <groupId>org.gatein.wsrp</groupId>
      <artifactId>wsrp-parent</artifactId>
      <version>2.1.1-CR02</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>

   <artifactId>wsrp-producer</artifactId>
   <packaging>war</packaging>
   <name>GateIn WSRP Producer WAR</name>

   <properties>
      <!-- the default jvmargs which should be used for the tests -->
      <!-- We need to set the STRICT_SERVLET_COMPLIANCE to false since we are using mock http requests -->
      <cargo.jvmargs.default>-Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false</cargo.jvmargs.default>
      <cargo.jvmargs>${cargo.jvmargs.default}</cargo.jvmargs>
   </properties>

   <profiles>
      <profile>
         <id>default</id>
         <activation>
            <activeByDefault>true</activeByDefault>
         </activation>
         <properties>
            <cargo.jvmargs>${cargo.jvmargs.default}</cargo.jvmargs>
         </properties>
      </profile>
      <profile>
         <id>cargo-debug</id>
         <properties>
            <!-- add the jdwp setup for the tests -->
            <cargo.jvmargs.debug>-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
            </cargo.jvmargs.debug>
            <cargo.jvmargs>${cargo.jvmargs.default} ${cargo.jvmargs.debug}</cargo.jvmargs>
         </properties>
      </profile>
      <profile>
         <!-- uses a zip of jboss as instead of an exploded directory -->
         <id>server-url</id>
         <activation>
            <property>
               <name>jboss.zip.url</name>
            </property>
         </activation>
         <properties>
            <jboss.systemPath>${jboss.zip.url}</jboss.systemPath>
            <JBOSS_5_1_0_HOME>${project.build.directory}/cargo/servers/jboss-5.1.0.GA</JBOSS_5_1_0_HOME>
         </properties>
         <dependencies>
            <dependency>
               <groupId>org.jboss.jbossas</groupId>
               <artifactId>jboss-as-distribution</artifactId>
               <version>5.1.0.GA</version>
               <scope>system</scope>
               <type>zip</type>
               <systemPath>${jboss.systemPath}</systemPath>
            </dependency>
         </dependencies>
         <build>
            <plugins>
               <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-dependency-plugin</artifactId>
                  <version>2.1</version>
                  <executions>
                     <execution>
                        <id>dependency-unpack</id>
                        <phase>process-test-resources</phase>
                        <goals>
                           <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                           <includeGroupIds>org.jboss.jbossas</includeGroupIds>
                           <includeArtifactIds>jboss-as-distribution</includeArtifactIds>
                           <outputDirectory>${project.build.directory}/cargo/servers</outputDirectory>
                        </configuration>
                     </execution>
                  </executions>
               </plugin>
            </plugins>
         </build>
      </profile>
      <profile>
         <id>test-server</id>
         <build>
            <plugins>
               <plugin>
                  <groupId>org.codehaus.cargo</groupId>
                  <artifactId>cargo-maven2-plugin</artifactId>
                  <version>1.0.1</version>
                  <configuration>
                     <wait>true</wait>
                  </configuration>
               </plugin>
            </plugins>
         </build>
      </profile>
      <profile>
         <id>integration-tests-enabled</id>
         <activation>
            <property>
               <name>!skipTests</name>
            </property>
         </activation>
         <build>
            <plugins>
               <plugin>
                  <groupId>org.codehaus.cargo</groupId>
                  <artifactId>cargo-maven2-plugin</artifactId>
                  <version>1.0.1</version>
                  <executions>
                     <execution>
                        <id>pre-integration-start-server</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                           <goal>start</goal>
                        </goals>
                     </execution>
                     <execution>
                        <id>post-integration-stop-server</id>
                        <phase>post-integration-test</phase>
                        <goals>
                           <goal>stop</goal>
                        </goals>
                     </execution>
                  </executions>
               </plugin>
               <plugin>
                  <artifactId>maven-assembly-plugin</artifactId>
                  <configuration>
                     <finalName>test</finalName>
                     <appendAssemblyId>true</appendAssemblyId>
                     <!-- we don't want to add these archives into the repo -->
                     <attach>false</attach>
                     <outputDirectory>${project.build.directory}/test-archives</outputDirectory>
                     <descriptors>
                        <descriptor>src/test/assembly/test-producer.xml</descriptor>
                        <descriptor>src/test/assembly/test-markup-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-renderparam-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-session-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-basic-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-dispatcher-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-getlocales-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-encodeurl-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-usercontext-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-multivalued-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-implicitcloning-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-resource-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-resourcenoencodeurl-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-applicationscope-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-portletstate-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-eventswithobject-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-events-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-portletmodes-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-prp-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-state-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-resourceserving-portlet.xml</descriptor>
                        <descriptor>src/test/assembly/test-windowstates-portlet.xml</descriptor>
                     </descriptors>
                  </configuration>
                  <executions>
                     <execution>
                        <id>assemble</id>
                        <!-- note that package phase happens after the test phase and before the integration test phase -->
                        <phase>package</phase>
                        <goals>
                           <goal>single</goal>
                        </goals>
                     </execution>
                  </executions>
                  <dependencies>
                     <dependency>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>jboss-packaging-maven-plugin</artifactId>
                        <version>2.1.1</version>
                     </dependency>
                  </dependencies>
               </plugin>
               <plugin>
                  <!-- Copy Google Portlet samples from PC module to test-archives so that they can be used in tests -->
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-dependency-plugin</artifactId>
                  <version>2.1</version>
                  <executions>
                     <execution>
                        <id>copy</id>
                        <goals>
                           <goal>copy</goal>
                        </goals>
                        <configuration>
                           <artifactItems>
                              <artifactItem>
                                 <groupId>org.gatein.pc</groupId>
                                 <artifactId>pc-samples</artifactId>
                                 <version>2.3.0-Beta06</version>
                                 <classifier>google-portlet</classifier>
                                 <type>war</type>
                                 <destFileName>google-portlet.war</destFileName>
                                 <outputDirectory>${project.build.directory}/test-archives</outputDirectory>
                              </artifactItem>
                           </artifactItems>
                        </configuration>
                     </execution>
                  </executions>
               </plugin>
            </plugins>
         </build>
      </profile>
   </profiles>

   <dependencies>
      <dependency>
         <groupId>org.gatein.wsrp</groupId>
         <artifactId>wsrp-producer-lib</artifactId>
      </dependency>
      <dependency>
         <groupId>org.gatein.wsrp</groupId>
         <artifactId>wsrp-wsrp1-ws</artifactId>
      </dependency>
      <dependency>
         <groupId>org.gatein.wsrp</groupId>
         <artifactId>wsrp-wsrp2-ws</artifactId>
      </dependency>
      <dependency>
         <groupId>org.gatein.wsrp</groupId>
         <artifactId>wsrp-common</artifactId>
      </dependency>

      <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>servlet-api</artifactId>
      </dependency>

      <dependency>
         <groupId>org.gatein.common</groupId>
         <artifactId>common-common</artifactId>
         <scope>provided</scope>
      </dependency>
      <dependency>
         <groupId>org.gatein.pc</groupId>
         <artifactId>pc-api</artifactId>
      </dependency>
      <dependency>
         <groupId>org.gatein.pc</groupId>
         <artifactId>pc-portlet</artifactId>
      </dependency>
      <dependency>
         <groupId>org.gatein.pc</groupId>
         <artifactId>pc-federation</artifactId>
      </dependency>

      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>commons-fileupload</groupId>
         <artifactId>commons-fileupload</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>javax.mail</groupId>
         <artifactId>mail</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.jboss</groupId>
         <artifactId>jbossxb</artifactId>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>org.gatein.wsrp</groupId>
         <artifactId>test-framework</artifactId>
         <scope>test</scope>
         <version>${project.version}</version>
      </dependency>
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-jdk14</artifactId>
         <scope>test</scope>
      </dependency>

      <!-- Producer Sar Test Dependencies -->
      <!-- TODO: move versioning to the main pom.xml -->
      <dependency>
         <groupId>org.gatein.wci</groupId>
         <artifactId>wci-tomcat6</artifactId>
         <scope>test</scope>
         <version>${org.gatein.wci.version}</version>
      </dependency>
      <dependency>
         <groupId>org.gatein.wsrp</groupId>
         <artifactId>wsrp-integration-api</artifactId>
         <scope>test</scope>
         <version>${project.version}</version>
      </dependency>
      <dependency>
         <groupId>org.gatein.pc</groupId>
         <artifactId>pc-controller</artifactId>
         <scope>test</scope>
         <version>${org.gatein.pc.version}</version>
      </dependency>
      <!-- Staxnav needed for PC -->
      <dependency>
         <groupId>org.staxnav</groupId>
         <artifactId>staxnav.core</artifactId>
         <version>0.9.6</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.8.1</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.jboss.arquillian</groupId>
         <artifactId>arquillian-api</artifactId>
         <version>${org.jboss.arquillian.version}</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.jboss.arquillian</groupId>
         <artifactId>arquillian-junit</artifactId>
         <version>${org.jboss.arquillian.version}</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.jboss.arquillian.container</groupId>
         <artifactId>arquillian-jbossas-remote-51</artifactId>
         <version>${org.jboss.arquillian.version}</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.jboss.jbossas</groupId>
         <artifactId>jboss-as-client</artifactId>
         <version>5.1.0.GA</version>
         <scope>test</scope>
         <type>pom</type>
         <exclusions>
            <exclusion>
               <groupId>trove</groupId>
               <artifactId>trove</artifactId>
            </exclusion>
            <exclusion>
               <groupId>org.jboss.ejb3</groupId>
               <artifactId>jboss-ejb3-core</artifactId>
            </exclusion>
            <exclusion>
               <groupId>org.jboss.ejb3</groupId>
               <artifactId>jboss-as-ejb3</artifactId>
            </exclusion>
            <exclusion>
               <groupId>javax.security</groupId>
               <artifactId>jaas</artifactId>
            </exclusion>
            <exclusion>
               <groupId>javax.security</groupId>
               <artifactId>jacc</artifactId>
            </exclusion>
            <exclusion>
               <groupId>cglib</groupId>
               <artifactId>cglib</artifactId>
            </exclusion>
            <exclusion>
               <groupId>jpl-util</groupId>
               <artifactId>jpl-util</artifactId>
            </exclusion>
            <exclusion>
               <groupId>jpl-pattern</groupId>
               <artifactId>jpl-pattern</artifactId>
            </exclusion>
         </exclusions>
      </dependency>
      <dependency>
         <groupId>trove</groupId>
         <artifactId>trove</artifactId>
         <version>1.0.2</version>
         <scope>test</scope>
      </dependency>
      <!--
      <dependency>
         <groupId>org.jboss.aop</groupId>
         <artifactId>jboss-aop</artifactId>
         <version>2.1.1.GA</version>
         <scope>test</scope>
         <exclusions>
            <exclusion>
               <groupId>trove</groupId>
               <artifactId>trove</artifactId>
            </exclusion>
         </exclusions>
      </dependency>
      -->
      <dependency>
         <groupId>org.jboss.jbossas</groupId>
         <artifactId>jboss-server-manager</artifactId>
         <version>1.0.3.GA</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.mockito</groupId>
         <artifactId>mockito-core</artifactId>
         <version>${org.mockito.version}</version>
         <scope>test</scope>
      </dependency>
   </dependencies>

   <build>
      <plugins>
         <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1-beta-1</version>
            <configuration>
               <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
               <archive>
                  <manifest>
                     <addClasspath>true</addClasspath>
                  </manifest>
               </archive>
            </configuration>
         </plugin>
         <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
            </configuration>
            <executions>
               <execution>
                  <goals>
                     <goal>test-jar</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
               <skip>true</skip>
               <excludes>
                  <exclude>org/gatein/wsrp/protocol/v1/*</exclude>
               </excludes>
               <!--<parallel>classes</parallel>
               <threadCount>2</threadCount>-->
            </configuration>
            <executions>
               <execution>
                  <id>integration-tests</id>
                  <phase>integration-test</phase>
                  <goals>
                     <goal>test</goal>
                  </goals>
                  <configuration>
                     <skip>${skipTests}</skip>
                     <includes>
                        <include>org/gatein/wsrp/protocol/v1/MarkupTestCase.class</include>
                        <include>org/gatein/wsrp/protocol/v1/PortletManagementTestCase.class</include>
                        <include>org/gatein/wsrp/protocol/v1/ReleaseSessionTestCase.class</include>
                        <include>org/gatein/wsrp/protocol/v1/ServiceDescriptionTestCase.class</include>
                        <include>org/gatein/wsrp/protocol/v1/RegistrationTestCase.class</include>
                        <include>org/gatein/wsrp/protocol/v2/MarkupTestCase.class</include>
                        <include>org/gatein/wsrp/protocol/v2/ServiceDescriptionTestCase.class</include>
                        <include>org/gatein/wsrp/protocol/v2/PortletManagementTestCase.class</include>
                     </includes>
                     <excludes>
                        <exclude>org/gatein/wsrp/producer/**</exclude>
                     </excludes>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.0.1</version>
            <configuration>
               <container>
                  <containerId>jboss51x</containerId>
                  <home>${JBOSS_5_1_0_HOME}</home>
                  <log>${basedir}/target/jboss51x/container.log</log>
                  <systemProperties>
                     <!-- Since the tests run on the server, we need to pass system properties to the
                          server so that the tests can use them. -->
                     <!-- The tests need to deploy and undeploy artifacts during the test so we need to pass
                          properties to enable this behaviour. -->
                     <jboss.deploy.dir>${jboss.server.home.dir}/conf</jboss.deploy.dir>
                     <test.deployables.dir>${basedir}/target/test-archives</test.deployables.dir>
                     <jboss.deploy.url.prefix>http://localhost:8080/jmx-console/HtmlAdaptor?action=invokeOpByName&amp;name=jboss.system:service%3DMainDeployer&amp;methodName=deploy&amp;argType=java.net.URL&amp;arg0=</jboss.deploy.url.prefix>
                     <jboss.undeploy.url.prefix>http://localhost:8080//jmx-console/HtmlAdaptor?action=invokeOpByName&amp;name=jboss.system:service%3DMainDeployer&amp;methodName=undeploy&amp;argType=java.net.URL&amp;arg0=</jboss.undeploy.url.prefix>
                  </systemProperties>
                  <timeout>180000</timeout>
               </container>
               <wait>false</wait>
               <configuration>
                  <home>${basedir}/target/cargo/standalone</home>
                  <properties>
                     <cargo.logging>low</cargo.logging>
                     <cargo.jvmargs>${cargo.jvmargs}</cargo.jvmargs>
                  </properties>
                  <deployables>
                     <deployable>
                        <location>${basedir}/target/test-archives/test-producer.sar</location>
                        <type>sar</type>
                     </deployable>
                  </deployables>
                  <configfiles>
                     <!-- hack to get normal logging instead of incredibly versbose -->
                     <configfile>
                        <file>${JBOSS_5_1_0_HOME}/server/default/conf/jboss-log4j.xml</file>
                        <tofile>/conf/jboss-log4j.xml</tofile>
                     </configfile>
                     <configfile>
                        <file>${basedir}/src/test/config/web.xml</file>
                        <tofile>/deployers/jbossweb.deployer/web.xml</tofile>
                     </configfile>
                  </configfiles>
               </configuration>
            </configuration>
         </plugin>
      </plugins>
      <testResources>
         <testResource>
            <directory>src/test/jboss-resources</directory>
         </testResource>
      </testResources>
   </build>
</project>
