<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source
  ~ Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
  ~ as indicated by the @authors tag. All rights reserved.
  ~ See the copyright.txt in the distribution for a
  ~ full listing of individual contributors.
  ~  *
  ~ This copyrighted material is made available to anyone wishing to use,
  ~ modify, copy, or redistribute it subject to the terms and conditions
  ~ of the GNU Lesser General Public License, v. 2.1.
  ~ This program is distributed in the hope that it will be useful, but WITHOUT A
  ~ 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,
  ~ v.2.1 along with this distribution; if not, write to the Free Software
  ~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  ~ MA  02110-1301, USA.
  -->

<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.switchyard</groupId>
        <artifactId>switchyard-release</artifactId>
        <version>0.1.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>org.switchyard</groupId>
    <artifactId>switchyard-release-test</artifactId>
    <version>0.1.0</version>
    <packaging>jar</packaging>
    <name>SwitchYard: Release Distribution Tests</name>
    <description>SwitchYard Release Distribution Tests</description>

    <!--
        Currently only has testing against AS6.  We will need to add profiles for testing
        against other containers.
    -->

    <properties>
        <switchyard.jboss.home>${project.build.directory}/switchyard-as6-0.1</switchyard.jboss.home>
        <arquillian.version>1.0.0.Alpha5</arquillian.version>
        <version.camel>2.6.0</version.camel>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.switchyard</groupId>
            <artifactId>switchyard-test</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
           <groupId>org.jboss.arquillian</groupId>
           <artifactId>arquillian-junit</artifactId>
            <version>${arquillian.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-jbossas-managed-6</artifactId>
            <version>${arquillian.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.shrinkwrap</groupId>
                    <artifactId>shrinkwrap-impl-base</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap</groupId>
            <artifactId>shrinkwrap-impl-base</artifactId>
            <version>1.0.0-alpha-12</version>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.shrinkwrap</groupId>
                    <artifactId>shrinkwrap-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jboss.shrinkwrap</groupId>
                    <artifactId>shrinkwrap-spi</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap</groupId>
            <artifactId>shrinkwrap-api</artifactId>
            <version>1.0.0-alpha-12</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap</groupId>
            <artifactId>shrinkwrap-spi</artifactId>
            <version>1.0.0-alpha-12</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
            <version>1.0.0-alpha-12</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.jbossas</groupId>
            <artifactId>jboss-as-depchain</artifactId>
            <version>6.0.0.Final</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-http4</artifactId>
            <version>${version.camel}</version>
            <scope>test</scope>
         </dependency>

    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.jbossas</groupId>
                <artifactId>jboss-as-depchain</artifactId>
                <version>6.0.0.Final</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <!-- Copy the SwitchYard AS6 distro to target/dependency -->
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>stage-jboss</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.switchyard</groupId>
                                    <artifactId>switchyard-release-as6</artifactId>
                                    <version>${project.version}</version>
                                    <type>zip</type>
                                    <destFileName>switchyard-release-as6.zip</destFileName> <!-- Need this setting because maven screws up if running from from parent dir. -->
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Unzip the SwitchYard AS6 distro ... -->
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <configuration>
                            <tasks>

                                <property name="dependencies.dir" value="${project.build.directory}/dependency"/>

                                <!-- Unzip the distribution... -->
                                <unzip src="${dependencies.dir}/switchyard-release-as6.zip"
                                       dest="${project.build.directory}"/>
				<!--
                                <chmod dir="${switchyard.jboss.home}/bin" perm="755" includes="*"/>
				-->
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Configure the Surefire plugin for running the tests.  Be sure to make these same setting if running in your IDE... -->
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <environmentVariables>
                        <JBOSS_HOME>${switchyard.jboss.home}</JBOSS_HOME>
                        <SWITCHYARD_VERSION>${project.version}</SWITCHYARD_VERSION>
                    </environmentVariables>
                    <additionalClasspathElements>
                        <additionalClasspathElement>${switchyard.jboss.home}/client/jbossws-native-client.jar</additionalClasspathElement>
                        <!--
                            Because jbossweb.sar contains shared web.xml, which must be
                            visible from same CL as TomcatDeployer.class.getClassLoader
                        -->
                        <additionalClasspathElement>${switchyard.jboss.home}/server/default/deploy/jbossweb.sar</additionalClasspathElement>
                    </additionalClasspathElements>

                    <trimStackTrace>false</trimStackTrace>
                    <printSummary>true</printSummary>
                    <forkMode>once</forkMode>

                    <!--
                        MaxPermSize Required to bump the space for relective data like
                        classes, methods, etc. EMB-41. Endorsed required for things like
                        WS support (EMB-61)
                    -->
                    <argLine>-Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Djava.endorsed.dirs=${switchyard.jboss.home}/lib/endorsed -Djboss.home=${switchyard.jboss.home}/ -Djboss.boot.server.log.dir=${switchyard.jboss.home}/</argLine>
                </configuration>
            </plugin>


        </plugins>
    </build>

</project>
