<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">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.atlassian.crowd</groupId>
        <artifactId>atlassian-crowd</artifactId>
        <version>2.2.0-m6</version>
    </parent>

    <artifactId>crowd-jira-test-runner</artifactId>
    <name>Atlassian Crowd-JIRA Test Runner Module</name>
    <packaging>pom</packaging>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowd-web-app</artifactId>
            <type>war</type>
        </dependency>

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowdified-jira-webapp</artifactId>
            <version>${project.version}</version>
            <type>war</type>
        </dependency>

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowd-acceptance-test</artifactId>
            <version>${project.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <!-- Needs to be compile at this point so cargo can access it, scope:test will not work -->
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
        </dependency>

        <dependency>
            <groupId>jotm</groupId>
            <artifactId>jotm</artifactId>
            <version>1.4.3</version>
        </dependency>

        <dependency>
            <groupId>jotm</groupId>
            <artifactId>objectweb-datasource</artifactId>
            <version>1.4.3</version>
        </dependency>

        <dependency>
            <groupId>jotm</groupId>
            <artifactId>jotm-jrmp_stubs</artifactId>
            <version>1.4.3</version>
        </dependency>

        <dependency>
            <groupId>jotm</groupId>
            <artifactId>jotm-iiop_stubs</artifactId>
            <version>1.4.3</version>
        </dependency>

        <dependency>
            <groupId>jotm</groupId>
            <artifactId>jonas_timer</artifactId>
            <version>1.4.3</version>
        </dependency>

        <dependency>
            <groupId>ots-jts</groupId>
            <artifactId>ots-jts</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>ots-jts</groupId>
            <artifactId>ots-jts</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>carol</groupId>
            <artifactId>carol</artifactId>
            <version>1.5.2</version>
        </dependency>

        <dependency>
            <groupId>carol</groupId>
            <artifactId>carol-properties</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>xapool</groupId>
            <artifactId>xapool</artifactId>
            <version>1.3.1</version>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>net.sourceforge.jwebunit</groupId>
            <artifactId>jwebunit-core</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>compile</scope>
        </dependency>

    </dependencies>

    <properties>
        <crowd.home>${project.build.directory}/crowd-home</crowd.home>
        <jira.home>${project.build.directory}/jira-home</jira.home>
        <acceptanceTestClassDirectory>${project.build.directory}/it-classes</acceptanceTestClassDirectory>

        <!-- Set to true (-Dcargo.wait=true) to make Cargo bring up the Crowd container and pause so you can figure
         out what you did wrong. -->
        <cargo.wait>false</cargo.wait>

        <!-- We are skipping by deault and explicitly setting this to true when we want to run this runner -->
        <maven.test.skip>true</maven.test.skip>

        <!-- please list ALL port configurations here -->
        <crowd.cargo.servlet.port>8095</crowd.cargo.servlet.port>
        <crowd.cargo.rmi.port>8195</crowd.cargo.rmi.port>
        <jira.cargo.servlet.port>8080</jira.cargo.servlet.port>
        <jira.cargo.rmi.port>8180</jira.cargo.rmi.port>

    </properties>


    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-func-tests</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>

                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.atlassian.crowd</groupId>
                                    <artifactId>crowd-acceptance-test</artifactId>
                                    <version>${project.version}</version>
                                </artifactItem>
                            </artifactItems>

                            <outputDirectory>${acceptanceTestClassDirectory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <executions>
                    <!--Crowd Container (crowd web-app)-->
                    <execution>
                        <id>start-crowd-container</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                            <skip>${maven.test.skip}</skip>
                            <wait>false</wait>
                            <container>
                                <containerId>tomcat6x</containerId>
                                <zipUrlInstaller>
                                    <url>
                                        https://m2proxy.atlassian.com/repository/public/org/apache/tomcat/apache-tomcat/${tomcat.version}/apache-tomcat-${tomcat.version}.zip
                                    </url>
                                </zipUrlInstaller>
                                <timeout>120000</timeout>
                                <output>${project.build.directory}/output-crowd.log</output>
                                <log>${project.build.directory}/cargo-crowd.log</log>
                                <systemProperties>
                                    <ldap.server.example.ldif>${acceptanceTestClassDirectory}/example.ldif
                                    </ldap.server.example.ldif>
                                </systemProperties>
                                <dependencies>
                                    <dependency>
                                        <groupId>hsqldb</groupId>
                                        <artifactId>hsqldb</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>javax.transaction</groupId>
                                        <artifactId>jta</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>javax.mail</groupId>
                                        <artifactId>mail</artifactId>
                                    </dependency>
                                </dependencies>
                            </container>
                            <configuration>
                                <home>${project.build.directory}/tomcat6x-crowd/container</home>
                                <properties>
                                    <cargo.servlet.port>${crowd.cargo.servlet.port}</cargo.servlet.port>
                                    <cargo.rmi.port>${crowd.cargo.rmi.port}</cargo.rmi.port>
                                    <cargo.logging>high</cargo.logging>
                                    <cargo.jvmargs>-Xms128m -Xmx512m -XX:MaxPermSize=256m -Dcrowd.home=${crowd.home}</cargo.jvmargs>
                                </properties>
                                <deployables>
                                    <deployable>
                                        <groupId>com.atlassian.crowd</groupId>
                                        <artifactId>crowd-web-app</artifactId>
                                        <type>war</type>
                                        <properties>
                                            <context>crowd</context>
                                        </properties>
                                        <pingURL>http://localhost:${crowd.cargo.servlet.port}/crowd</pingURL>
                                        <pingTimeout>240000</pingTimeout>
                                    </deployable>
                                </deployables>
                            </configuration>
                        </configuration>
                    </execution>

                    <!-- JIRA Container (jira web-app) -->
                    <execution>
                        <id>start-jira-container</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                            <skip>${maven.test.skip}</skip>
                            <wait>${cargo.wait}</wait>
                            <container>
                                <containerId>tomcat6x</containerId>
                                <zipUrlInstaller>
                                    <url>
                                        https://m2proxy.atlassian.com/repository/public/org/apache/tomcat/apache-tomcat/${tomcat.version}/apache-tomcat-${tomcat.version}.zip
                                    </url>
                                </zipUrlInstaller>
                                <timeout>120000</timeout>
                                <output>${project.build.directory}/output-jira.log</output>
                                <log>${project.build.directory}/cargo-jira.log</log>
                                <dependencies>
                                    <dependency>
                                        <groupId>hsqldb</groupId>
                                        <artifactId>hsqldb</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>javax.transaction</groupId>
                                        <artifactId>jta</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>jotm</groupId>
                                        <artifactId>jotm</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>jotm</groupId>
                                        <artifactId>objectweb-datasource</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>jotm</groupId>
                                        <artifactId>jotm-jrmp_stubs</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>jotm</groupId>
                                        <artifactId>jotm-iiop_stubs</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>jotm</groupId>
                                        <artifactId>jonas_timer</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>ots-jts</groupId>
                                        <artifactId>ots-jts</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>carol</groupId>
                                        <artifactId>carol</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>carol</groupId>
                                        <artifactId>carol-properties</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>xapool</groupId>
                                        <artifactId>xapool</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>commons-logging</groupId>
                                        <artifactId>commons-logging</artifactId>
                                    </dependency>
                                </dependencies>
                            </container>
                            <configuration>
                                <home>${project.build.directory}/tomcat6x-jira/container</home>
                                <properties>
                                    <cargo.servlet.port>${jira.cargo.servlet.port}</cargo.servlet.port>
                                    <cargo.rmi.port>${jira.cargo.rmi.port}</cargo.rmi.port>
                                    <cargo.logging>high</cargo.logging>
                                    <cargo.jvmargs>
                                        -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dcrowd.properties=${acceptanceTestClassDirectory}/localtest.jira.properties -Djira.home=${jira.home}
                                    </cargo.jvmargs>
                                    <cargo.datasource.datasource>
                                        cargo.datasource.url=jdbc:hsqldb:mem:jira_cargo|
                                        cargo.datasource.driver=org.hsqldb.jdbcDriver|
                                        cargo.datasource.username=sa|cargo.datasource.password=|
                                        cargo.datasource.type=javax.sql.DataSource|
                                        cargo.datasource.jndi=jdbc/JiraDS
                                    </cargo.datasource.datasource>
                                    <cargo.resource.resource.transaction>
                                        cargo.resource.name=UserTransaction
                                        cargo.resource.auth=Container|
                                        cargo.resource.type=javax.transaction.UserTransaction
                                        cargo.resource.parameters=factory=org.objectweb.jotm.UserTransactionFactory;jotm.timeout=60
                                    </cargo.resource.resource.transaction>
                                </properties>
                                <deployables>
                                    <deployable>
                                        <groupId>com.atlassian.crowd</groupId>
                                        <artifactId>crowdified-jira-webapp</artifactId>
                                        <type>war</type>
                                        <properties>
                                            <context>jira</context>
                                        </properties>
                                        <pingURL>http://localhost:${jira.cargo.servlet.port}/jira</pingURL>
                                        <pingTimeout>240000</pingTimeout>
                                    </deployable>
                                </deployables>
                            </configuration>
                        </configuration>
                    </execution>

                </executions>

            </plugin>

        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <!--
                    Configure Surefire to run in the integration-test phase, but not in the
                     normal test phase.
                    -->
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>

                    <configuration>

                        <argLine>-Xmx128m</argLine>

                        <systemProperties>
                            <property>
                                <name>crowd.home</name>
                                <value>${crowd.home}</value>
                            </property>
                        </systemProperties>

                    </configuration>

                    <executions>
                        <!-- first setup Crowd -->
                        <execution>
                            <id>setup-crowd</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>**/SetupCrowdTest.java</include>
                                </includes>
                                <skip>${maven.test.skip}</skip>
                                <testClassesDirectory>${acceptanceTestClassDirectory}</testClassesDirectory>
                            </configuration>
                        </execution>

                        <!-- then setup JIRA -->
                        <execution>
                            <id>setup-jira</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>**/SetupJiraTest.java</include>
                                </includes>
                                <skip>${maven.test.skip}</skip>
                                <testClassesDirectory>${acceptanceTestClassDirectory}</testClassesDirectory>
                            </configuration>
                        </execution>

                        <!-- then run the JIRA test suite -->
                        <execution>
                            <id>run-crowd-jira-tests</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>**/JiraCrowdAcceptanceTestHarness.java</include>
                                </includes>
                                <skip>${maven.test.skip}</skip>
                                <testClassesDirectory>${acceptanceTestClassDirectory}</testClassesDirectory>
                            </configuration>
                        </execution>

                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

