<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.0.9</version>
    </parent>

    <artifactId>crowd-test-runner</artifactId>
    <name>Atlassian Crowd Acceptance 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>crowd-demo-app</artifactId>
            <type>war</type>
        </dependency>

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowd-openid-server</artifactId>
            <type>war</type>
        </dependency>

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowd-openid-client</artifactId>
            <type>war</type>
        </dependency>

        <dependency>
            <groupId>com.atlassian.ldap</groupId>
            <artifactId>atlassian-ldap-test-webapp</artifactId>
            <version>5</version>
            <type>war</type>
        </dependency>

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowd-apacheds-server</artifactId>
            <version>${project.version}</version>
            <type>war</type>
        </dependency>

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowd-acceptance-test</artifactId>
            <version>${project.version}</version>
        </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>com.atlassian.crowd</groupId>
            <artifactId>crowd-selenium-test</artifactId>
            <version>${project.version}</version>
        </dependency>

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

    <properties>
        <crowd.home>${project.build.directory}/crowd-home</crowd.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>
        <!-- Set to false (-Dselenium.test.skip=false) to run selenium tests -->
        <selenium.test.skip>true</selenium.test.skip>
        <!-- By default same as maven.test.skip. Running the selenium profile will change this value to allow crowd to setup -->
        <crowd.setup.skip>${maven.test.skip}</crowd.setup.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>
        <crowdid.cargo.servlet.port>8097</crowdid.cargo.servlet.port>
        <crowdid.cargo.rmi.port>8197</crowdid.cargo.rmi.port>
        <apacheds.ldap.port>11389</apacheds.ldap.port>
        <apacheds.1.5.ldap.port>12389</apacheds.1.5.ldap.port>

        <!-- Selenium properties -->
        <!-- Overide with -Dselenium.browser='*firefox /Applications/path/to/firefox2' in command line -->
        <selenium.browser>*firefox</selenium.browser>
        <selenium.xvfb.skip>true</selenium.xvfb.skip>
        <selenium.max.wait.time>10000</selenium.max.wait.time>
        <selenium.server.port>4448</selenium.server.port>
        <!-- Confluence uses 4444 -->
        <selenium.server.location>localhost</selenium.server.location>
        <selenium.firefox.profile />

        <crowd.context>crowd</crowd.context>
        <crowd.url>http://${selenium.server.location}:${crowd.cargo.servlet.port}/${crowd.context}/</crowd.url>
        <crowd.test.exclusion.suffix>NotFirefoxTest</crowd.test.exclusion.suffix>

    </properties>


    <!-- Selenium profiles -->
    <profiles>

        <profile>
            <id>bamboo-firefox</id>
            <properties>
                <selenium.browser>*firefox /opt/firefox/firefox-bin</selenium.browser>
                <selenium.xvfb.skip>false</selenium.xvfb.skip>
                <selenium.max.wait.time>12000</selenium.max.wait.time>
            </properties>

        </profile>

        <profile>
            <id>local-firefox-mac</id>
            <properties>
                <selenium.browser>*firefox /Applications/Firefox 2.app/Contents/MacOS/firefox-bin</selenium.browser>
                <selenium.xvfb.skip>false</selenium.xvfb.skip>
                <selenium.max.wait.time>12000</selenium.max.wait.time>
            </properties>

        </profile>

        <profile>
            <id>safari</id>
            <properties>
                <selenium.browser>*safari</selenium.browser>
                <selenium.xvfb.skip>true</selenium.xvfb.skip>
                <crowd.test.exclusion.suffix>NotSafariTest</crowd.test.exclusion.suffix>
            </properties>
        </profile>

        <profile>
            <id>vmwarevista-ie7</id>
            <properties>
                <selenium.browser>*iexplore</selenium.browser>
                <selenium.xvfb.skip>true</selenium.xvfb.skip>
                <crowd.test.exclusion.suffix>NotIExploreTest</crowd.test.exclusion.suffix>
                <selenium.max.wait.time>15000</selenium.max.wait.time>
            </properties>
        </profile>
        <profile>
            <id>vmwarevista-ie6</id>
            <properties>
                <selenium.browser>*iexplore</selenium.browser>
                <selenium.xvfb.skip>true</selenium.xvfb.skip>
                <crowd.test.exclusion.suffix>NotIExploreTest</crowd.test.exclusion.suffix>
            </properties>
        </profile>

        <!-- Special profile to run Selenium tests. -->
        <profile>
            <id>selenium</id>
            <properties>
                <!-- We want to setup crowd to run selenium tests -->
                <crowd.setup.skip>false</crowd.setup.skip>
                <selenium.test.skip>false</selenium.test.skip>
            </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>
                                        <artifactItem>
                                            <groupId>com.atlassian.crowd</groupId>
                                            <artifactId>crowd-selenium-test</artifactId>
                                            <version>${project.version}</version>
                                        </artifactItem>
                                    </artifactItems>
                                    
                                    <outputDirectory>${acceptanceTestClassDirectory}</outputDirectory>
                                </configuration>

                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>selenium-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-xvfb-instance</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>xvfb</goal>
                                </goals>
                                <configuration>
                                    <skip>${selenium.xvfb.skip}</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>start-selenium-server</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start-server</goal>
                                </goals>
                                <configuration>
                                    <background>true</background>
                                    <port>${selenium.server.port}</port>
                                    <firefoxProfileTemplate>${selenium.firefox.profile}</firefoxProfileTemplate>
                                    <skip>${selenium.test.skip}</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>stop-selenium-server</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop-server</goal>
                                </goals>
                                <configuration>
                                    <port>${selenium.server.port}</port>
                                    <skip>${selenium.test.skip}</skip>
                                </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>
                                <!-- skip unit tests -->
                                <skip>true</skip>
                                <!-- debugForkedProcess>true</debugForkedProcess -->
                                <testClassesDirectory>${acceptanceTestClassDirectory}</testClassesDirectory>

                                <!-- Selenium properties -->
                                <systemProperties>
                                    <property>
                                        <name>crowd.url</name>
                                        <value>${crowd.url}</value>
                                    </property>

                                    <property>
                                        <name>selenium.server.location</name>
                                        <value>${selenium.server.location}</value>
                                    </property>

                                    <property>
                                        <name>selenium.port</name>
                                        <value>${selenium.server.port}</value>
                                    </property>

                                    <property>
                                        <name>selenium.browser</name>
                                        <value>${selenium.browser}</value>
                                    </property>
                                    <property>
                                        <name>selenium.max.wait.time</name>
                                        <value>${selenium.max.wait.time}</value>
                                    </property>
                                </systemProperties>

                            </configuration>

                            <executions>
                                <!-- Run Crowd UI/Selenium tests -->
                                <execution>
                                    <id>test-crowd-selenium</id>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <phase>integration-test</phase>
                                    <configuration>
                                        <includes>
                                            <include>**/CrowdSeleniumTestHarness.java</include>
                                        </includes>
                                        <argLine>-Xmx256m -Dcrowd.home=${crowd.home}</argLine>
                                        <skip>${selenium.test.skip}</skip>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>

            </build>
        </profile>
    </profiles>

    <!-- Normal acceptance test build configuration -->
    <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 / security server) + Demo App + Apache DS -->
                    <execution>
                        <id>start-crowd-container</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                            <skip>${crowd.setup.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-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>-XX:MaxPermSize=256m -Xms128m -Xmx512m -Dldap.server.port=${apacheds.ldap.port} -Dcrowd.home=${crowd.home} -Dapacheds.ldap.port=${apacheds.1.5.ldap.port}
                                    </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>
                                    <deployable>
                                        <groupId>com.atlassian.crowd</groupId>
                                        <artifactId>crowd-demo-app</artifactId>
                                        <type>war</type>
                                        <properties>
                                            <context>demo</context>
                                        </properties>
                                        <pingURL>http://localhost:${crowd.cargo.servlet.port}/demo</pingURL>
                                        <pingTimeout>240000</pingTimeout>
                                    </deployable>
                                    <deployable>
                                        <groupId>com.atlassian.ldap</groupId>
                                        <artifactId>atlassian-ldap-test-webapp</artifactId>
                                        <type>war</type>
                                        <properties>
                                            <context>apacheds</context>
                                        </properties>
                                        <pingURL>http://localhost:${crowd.cargo.servlet.port}/apacheds</pingURL>
                                        <pingTimeout>240000</pingTimeout>
                                    </deployable>
                                    <deployable>
                                        <groupId>com.atlassian.crowd</groupId>
                                        <artifactId>crowd-apacheds-server</artifactId>
                                        <type>war</type>
                                        <properties>
                                            <context>apacheds15</context>
                                        </properties>
                                        <pingURL>http://localhost:${crowd.cargo.servlet.port}/apacheds15</pingURL>
                                        <pingTimeout>240000</pingTimeout>
                                    </deployable>
                                </deployables>
                            </configuration>
                        </configuration>
                    </execution>
                    <!-- CrowdID Container (openid server + client) -->
                    <execution>
                        <id>start-crowdid-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-crowdid.log</output>
                                <log>${project.build.directory}/cargo-crowdid.log</log>
                                <dependencies>
                                    <dependency>
                                        <groupId>hsqldb</groupId>
                                        <artifactId>hsqldb</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>javax.transaction</groupId>
                                        <artifactId>jta</artifactId>
                                    </dependency>
                                </dependencies>
                            </container>
                            <configuration>
                                <home>${project.build.directory}/tomcat6x-crowdid/container</home>
                                <properties>
                                    <cargo.servlet.port>${crowdid.cargo.servlet.port}</cargo.servlet.port>
                                    <cargo.rmi.port>${crowdid.cargo.rmi.port}</cargo.rmi.port>
                                    <cargo.logging>high</cargo.logging>
                                    <cargo.jvmargs>
                                        -Dcrowd.properties=${acceptanceTestClassDirectory}/localtest.crowdid.properties
                                    </cargo.jvmargs>
                                    <cargo.datasource.datasource>
                                        cargo.datasource.url=jdbc:hsqldb:mem:crowdid_cargo|
                                        cargo.datasource.driver=org.hsqldb.jdbcDriver|
                                        cargo.datasource.username=sa|cargo.datasource.password=|
                                        cargo.datasource.type=javax.sql.DataSource|
                                        cargo.datasource.jndi=jdbc/CrowdIDDS
                                    </cargo.datasource.datasource>
                                </properties>
                                <deployables>
                                    <deployable>
                                        <groupId>com.atlassian.crowd</groupId>
                                        <artifactId>crowd-openid-server</artifactId>
                                        <type>war</type>
                                        <properties>
                                            <context>openidserver</context>
                                        </properties>
                                        <pingURL>http://localhost:${crowdid.cargo.servlet.port}/openidserver</pingURL>
                                        <pingTimeout>240000</pingTimeout>
                                    </deployable>
                                    <deployable>
                                        <groupId>com.atlassian.crowd</groupId>
                                        <artifactId>crowd-openid-client</artifactId>
                                        <type>war</type>
                                        <properties>
                                            <context>openidclient</context>
                                        </properties>
                                        <pingURL>http://localhost:${crowdid.cargo.servlet.port}/openidclient</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>
                        <!-- skip unit tests -->
                        <skip>true</skip>
                        <!-- debugForkedProcess>true</debugForkedProcess -->
                        <testClassesDirectory>${acceptanceTestClassDirectory}</testClassesDirectory>
                    </configuration>

                    <executions>
                        <execution>
                            <id>crowd-persistence</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>com/atlassian/crowd/acceptance/tests/persistence/**/*Test.java</include>
                                </includes>
                                <argLine>-Xmx128m</argLine>
                                <skip>${maven.test.skip}</skip>
                            </configuration>
                        </execution>

                        <!-- first setup Crowd with Demo App and CrowdID -->
                        <execution>
                            <id>setup-crowd</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>**/SetupCrowdTest.java</include>
                                </includes>
                                <argLine>-Xmx128m</argLine>
                                <skip>${crowd.setup.skip}</skip>
                            </configuration>
                        </execution>

                        <!-- run Crowd functional tests -->
                        <execution>
                            <id>test-crowd</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>**/CrowdAcceptanceTestHarness.java</include>
                                </includes>
                                <argLine>-Xmx256m -Dcrowd.home=${crowd.home}</argLine>
                                <skip>${maven.test.skip}</skip>
                            </configuration>
                        </execution>

                        <execution>
                            <id>test-demo</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>**/DemoAcceptanceTestHarness.java</include>
                                </includes>
                                <argLine>-Xmx256m</argLine>
                                <skip>${maven.test.skip}</skip>
                            </configuration>
                        </execution>

                        <!-- run CrowdID functional tests -->
                        <execution>
                            <id>test-crowdid</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>**/CrowdIDAcceptanceTestHarness.java</include>
                                </includes>
                                <argLine>-Xmx128m</argLine>
                                <skip>${maven.test.skip}</skip>
                            </configuration>
                        </execution>

                        <!-- run Crowd Remote Directory functional tests -->
                        <execution>
                            <id>test-crowddirectory</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>**/CrowdDirectoryTestHarness.java</include>
                                </includes>
                                <argLine>-Xmx256m</argLine>
                                <skip>${maven.test.skip}</skip>
                            </configuration>
                        </execution>

                        <!-- run Crowd client libraries functional tests -->
                        <execution>
                            <id>test-crowd-integration-client</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>**/CrowdIntegrationClientTestHarness.java</include>
                                </includes>
                                <argLine>-Xmx256m</argLine>
                                <skip>${maven.test.skip}</skip>
                            </configuration>
                        </execution>

                        <!-- run Crowd REST API functional tests -->
                        <execution>
                            <id>test-crowd-admin</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>**/RestAcceptanceTestHarness.java</include>
                                </includes>
                                <argLine>-Xmx256m</argLine>
                                <skip>${maven.test.skip}</skip>
                            </configuration>
                        </execution>

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