<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.9.0-OD-046</version>
    </parent>

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

    <modules>
        <!-- Running on Windows with a local SQL Server database -->
        <module>crowd-sql-server-upgrade-test</module>

        <!-- Testing the DAOs against real databases -->
        <module>crowd-dao-database-test</module>
    </modules>

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

        <dependency>
            <groupId>org.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>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <!-- Needs to be compile at this point so cargo can access it, scope:test will not work -->
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>net.sourceforge.jtds</groupId>
            <artifactId>jtds</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</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.mail</groupId>
            <artifactId>mail</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>

        <dependency>
            <groupId>net.sourceforge.jwebunit</groupId>
            <artifactId>jwebunit-htmlunit-plugin</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
            <artifactId>nekohtml</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <scope>runtime</scope>
        </dependency>

    </dependencies>

    <properties>
        <crowd.home>${project.build.directory}/crowd-home</crowd.home>
        <crowd2.home>${project.build.directory}/crowd2-home</crowd2.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>
        <cargo.wait.crowdid>false</cargo.wait.crowdid>
        <cargo.pingTimeout>${cargo.timeout}</cargo.pingTimeout>
        <!-- Set to false (-Dselenium.background=false) to run selenium server and wait (similar to cargo's run/wait) -->
        <selenium.background>true</selenium.background>
        <!-- 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>
        <crowd.cargo.debug /> <!-- set in the debug profile if activated -->
        <crowd2.cargo.servlet.port>8096</crowd2.cargo.servlet.port>
        <crowd2.cargo.rmi.port>8196</crowd2.cargo.rmi.port>
        <crowd2.cargo.debug />
        <crowdid.cargo.servlet.port>8097</crowdid.cargo.servlet.port>
        <crowdid.cargo.rmi.port>8197</crowdid.cargo.rmi.port>
        <crowdid.cargo.debug />
        <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>
        <selenium.browser.path>/opt/firefox/firefox-7.0/firefox-bin</selenium.browser.path>
        <!-- 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>

        <loadTestFilename>${tpm.loadtest.file}</loadTestFilename>
        <databaseType>${database.type}</databaseType>
        <databaseUsername>${database.username}</databaseUsername>
        <databasePassword>${database.password}</databasePassword>
        <databaseDriver>${database.driver}</databaseDriver>
        <databaseDialect>${database.dialect}</databaseDialect>
        <databaseUrl>${database.url}</databaseUrl>
        <license.scope>test</license.scope>
    </properties>


    <profiles>
        <profile>
            <id>debug</id>
            <properties>
                <crowd.cargo.debug>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005</crowd.cargo.debug>
                <crowd2.cargo.debug>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006</crowd2.cargo.debug>
                <crowdid.cargo.debug>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5007</crowdid.cargo.debug>
            </properties>
        </profile>

        <!-- Don't re-run the acceptance tests in release:perform -->
        <profile>
            <id>release</id>
            <properties>
                <maven.test.skip>true</maven.test.skip>
            </properties>
        </profile>

        <!-- Selenium profiles -->
        <profile>
            <id>bamboo-firefox</id>
            <properties>
                <selenium.browser>*firefox ${selenium.browser.path}</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.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>local-firefox-linux</id>
            <properties>
                <selenium.browser>*firefox /usr/bin/firefox</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>
                        <version>2.3</version>
                        <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>${selenium.background}</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>acceptance.test.crowd.port</name>
                                        <value>${crowd.cargo.servlet.port}</value>
                                    </property>
                                    <property>
                                        <name>acceptance.test.crowdid.port</name>
                                        <value>${crowdid.cargo.servlet.port}</value>
                                    </property>
                                    <property>
                                        <name>acceptance.test.crowdidclient.port</name>
                                        <value>${crowdid.cargo.servlet.port}</value>
                                    </property>
                                    <property>
                                        <name>acceptance.test.demo.port</name>
                                        <value>${crowd.cargo.servlet.port}</value>
                                    </property>
                                    <property>
                                        <name>crowd.property.crowd.server.url</name>
                                        <value>http://localhost:${crowd.cargo.servlet.port}/crowd</value>
                                    </property>
                                    <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>

        <!-- LabManager profile -->
        <profile>
            <id>tpm</id>
            <properties>
                <crowd.setup.skip>false</crowd.setup.skip>
            </properties>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>

                            <configuration>
                                <!-- skip unit tests -->
                                <skip>true</skip>
                                <!-- debugForkedProcess>true</debugForkedProcess -->
                                <testClassesDirectory>${acceptanceTestClassDirectory}</testClassesDirectory>

                                <systemProperties>
                                    <property>
                                        <name>tpm.ad2k3.filename</name>
                                        <value>crowd-tpm.properties</value>
                                    </property>
                                </systemProperties>

                            </configuration>

                            <executions>
                                <!-- Run AD2K3 tests -->
                                <execution>
                                    <id>test-ad2k3</id>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <phase>integration-test</phase>
                                    <configuration>
                                        <includes>
                                            <include>**/ActiveDirectory2K3Test.java</include>
                                        </includes>
                                        <argLine>-Xmx256m -Dcrowd.home=${crowd.home}</argLine>
                                        <skip>false</skip>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <!-- LabManager profile for load testing -->
        <profile>
            <id>tpm-loadTest10k</id>
            <properties>
                <crowd.setup.skip>false</crowd.setup.skip>
                <maven.test.skip>true</maven.test.skip>
            </properties>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>

                            <configuration>
                                <!-- skip unit tests -->
                                <skip>true</skip>
                                <!-- debugForkedProcess>true</debugForkedProcess -->
                                <testClassesDirectory>${acceptanceTestClassDirectory}</testClassesDirectory>
                                <systemProperties>
                                    <property>
                                        <name>tpm.loadtest.file</name>
                                        <value>${loadTestFilename}</value>
                                    </property>
                                    <property>
                                        <name>database.type</name>
                                        <value>${databaseType}</value>
                                    </property>
                                    <property>
                                        <name>database.username</name>
                                        <value>${databaseUsername}</value>
                                    </property>
                                    <property>
                                        <name>database.password</name>
                                        <value>${databasePassword}</value>
                                    </property>
                                    <property>
                                        <name>database.driver</name>
                                        <value>${databaseDriver}</value>
                                    </property>
                                    <property>
                                        <name>database.url</name>
                                        <value>${databaseUrl}</value>
                                    </property>
                                    <property>
                                        <name>database.dialect</name>
                                        <value>${databaseDialect}</value>
                                    </property>
                                </systemProperties>


                            </configuration>

                            <executions>
                                <!--
                                Override the default setup-crowd execution with one that
                                sets up Crowd with a specified database
                                 Note: To specify specific database details need to provide values for:
                                    database.type, database.username, database.password, database.driver, database.dialect, database.url
                                 Otherwise it will fallback to HSQLDB
                                -->
                                <execution>
                                    <id>setup-crowd</id>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <phase>integration-test</phase>
                                    <configuration>

                                        <includes>
                                            <include>**/SetupCrowdWithDatabase.java</include>
                                        </includes>
                                        <argLine>-Xmx128m</argLine>
                                        <skip>false</skip>
                                    </configuration>

                                </execution>

                                <!-- Run load tests for AD2K3 -->
                                <execution>
                                    <id>loadtest-ad2k3</id>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <phase>integration-test</phase>
                                    <configuration>
                                        <includes>
                                            <include>**/DbCachingLoadTestHarness.java</include>
                                        </includes>
                                        <argLine>-Xmx512m -Dcrowd.home=${crowd.home}</argLine>
                                        <skip>false</skip>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <!-- profile for running Java-based performance tests that don't need external LDAP servers -->
        <profile>
            <id>performance</id>
            <properties>
                <crowd.setup.skip>false</crowd.setup.skip>
                <maven.test.skip>true</maven.test.skip>
            </properties>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <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>
                                <!-- run performance tests -->
                                <execution>
                                    <id>test-performance</id>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <phase>integration-test</phase>
                                    <configuration>
                                        <includes>
                                            <include>**/CrowdPerformanceTestHarness.java</include>
                                        </includes>
                                        <argLine>-Xmx256m -Dcrowd.home=${crowd.home}</argLine>
                                        <skip>false</skip>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <profile>
            <id>file-configuration-tests</id>
            <modules>
                <!-- Testing the file-based configuration DAO -->
                <module>crowd-file-configuration-test</module>
            </modules>
        </profile>

        <profile>
            <id>remote-crowd-acceptance-tests</id>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.codehaus.cargo</groupId>
                            <artifactId>cargo-maven2-plugin</artifactId>
                            <executions>
                                <!-- Crowd Container #1 is started and stopped by the main pom (w/o any profile) -->

                                <!-- Crowd Container #2 (crowd web-app) -->
                                <execution>
                                    <id>start-crowd2-container</id>
                                    <phase>pre-integration-test</phase>
                                    <goals>
                                        <goal>start</goal>
                                    </goals>
                                    <configuration>
                                        <skip>${crowd.setup.skip}</skip>
                                        <wait>false</wait>
                                        <container>
                                            <output>${project.build.directory}/output-crowd2.log</output>
                                            <log>${project.build.directory}/cargo-crowd2.log</log>
                                            <dependencies>
                                                <dependency>
                                                    <groupId>org.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}/${cargo.containerid}-crowd2/container</home>
                                            <properties>
                                                <cargo.servlet.port>${crowd2.cargo.servlet.port}</cargo.servlet.port>
                                                <cargo.rmi.port>${crowd2.cargo.rmi.port}</cargo.rmi.port>
                                                <cargo.servlet.uriencoding>UTF-8</cargo.servlet.uriencoding>
                                                <cargo.jvmargs>${crowd2.cargo.debug} -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dcrowd.home=${crowd2.home} -Dcrowd.polling.startdelay=86400000 -Djava.awt.headless=true</cargo.jvmargs>
                                            </properties>
                                        </configuration>
                                        <deployables>
                                            <deployable>
                                                <groupId>com.atlassian.crowd</groupId>
                                                <artifactId>crowd-web-app</artifactId>
                                                <type>war</type>
                                                <properties>
                                                    <context>crowd</context>
                                                </properties>
                                                <!-- ping a URL that is not Johnson-protected and returns HTTP 200 -->
                                                <pingURL>http://localhost:${crowd2.cargo.servlet.port}/crowd/console/favicon.ico</pingURL>
                                                <pingTimeout>${cargo.pingTimeout}</pingTimeout>
                                            </deployable>
                                        </deployables>
                                    </configuration>
                                </execution>

                                <execution>
                                    <id>stop-crowd2-container</id>
                                    <phase>post-integration-test</phase>
                                    <goals>
                                        <goal>stop</goal>
                                    </goals>
                                    <configuration>
                                        <skip>${crowd.setup.skip}</skip>
                                        <configuration>
                                            <home>${project.build.directory}/${cargo.containerid}-crowd2/container</home>
                                            <properties>
                                                <cargo.servlet.port>${crowd2.cargo.servlet.port}</cargo.servlet.port>
                                                <cargo.jvmargs>-Djava.awt.headless=true</cargo.jvmargs>
                                            </properties>
                                        </configuration>
                                    </configuration>
                                </execution>

                            </executions>

                        </plugin>

                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>

                            <!-- configuration is inherited from the main pom (w/o any profile) -->

                            <executions>
                                <!-- Crowd #1 is setup by the main pom (w/o any profile) -->

                                <!-- then setup Crowd #2 -->
                                <execution>
                                    <id>setup-crowd2</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>
                                        <systemProperties>
                                            <property>
                                                <name>acceptance.test.crowd.port</name>
                                                <value>${crowd2.cargo.servlet.port}</value>
                                            </property>
                                            <property>
                                                <name>crowd.property.crowd.server.url</name>
                                                <value>http://localhost:${crowd2.cargo.servlet.port}/crowd</value>
                                            </property>
                                        </systemProperties>
                                    </configuration>
                                </execution>

                                <!-- run Remote Crowd tests -->
                                <execution>
                                    <id>test-remote-crowd</id>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <phase>integration-test</phase>
                                    <configuration>
                                        <includes>
                                            <include>**/RemoteCrowdAcceptanceTestHarness.java</include>
                                        </includes>
                                        <argLine>-Xmx256m -Dcrowd.home=${crowd.home}</argLine>
                                        <skip>${maven.test.skip}</skip>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <profile>
            <!-- Runs Crowd (the web-app) console acceptance tests -->
            <id>web-app-console-acceptance-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <!-- run Crowd functional tests -->
                            <execution>
                                <id>test-crowd</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>**/CrowdWebAppConsoleAcceptanceTestHarness.java</include>
                                    </includes>
                                    <argLine>-Xmx256m -Dcrowd.home=${crowd.home}</argLine>
                                    <skip>${maven.test.skip}</skip>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- Runs Crowd (the web-app) other acceptance tests -->
            <id>web-app-other-acceptance-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <!-- run Crowd functional tests -->
                            <execution>
                                <id>test-crowd</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>**/CrowdWebAppOtherAcceptanceTestHarness.java</include>
                                    </includes>
                                    <argLine>-Xmx256m -Dcrowd.home=${crowd.home}</argLine>
                                    <skip>${maven.test.skip}</skip>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- Starts CrowdID and runs bundled apps (Demo app + Crowd OpenID) acceptance tests -->
            <id>bundled-apps-acceptance-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>test-demo</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>**/DemoAcceptanceTestHarness.java</include>
                                    </includes>
                                    <argLine>-Xmx64m</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>-Xmx64m</argLine>
                                    <skip>${maven.test.skip}</skip>
                                    <systemProperties>
                                        <property>
                                            <name>acceptance.test.crowd.port</name>
                                            <value>${crowd.cargo.servlet.port}</value>
                                        </property>
                                        <property>
                                            <name>acceptance.test.crowdid.port</name>
                                            <value>${crowdid.cargo.servlet.port}</value>
                                        </property>
                                        <property>
                                            <name>acceptance.test.crowdidclient.port</name>
                                            <value>${crowdid.cargo.servlet.port}</value>
                                        </property>
                                        <property>
                                            <name>crowd.property.crowd.server.url</name>
                                            <value>http://localhost:${crowd.cargo.servlet.port}/crowd</value>
                                        </property>
                                        <property>
                                            <name>crowd.property.application.login.url</name>
                                            <value>http://localhost:${crowdid.cargo.servlet.port}/openidserver</value>
                                        </property>
                                    </systemProperties>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <executions>
                            <!-- 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>${cargo.wait.crowdid}</wait>
                                    <container>
                                        <output>${project.build.directory}/output-crowdid.log</output>
                                        <log>${project.build.directory}/cargo-crowdid.log</log>
                                        <systemProperties>
                                            <crowd.openid.home>${acceptanceTestClassDirectory}/openid-server-home</crowd.openid.home>
                                        </systemProperties>
                                        <dependencies>
                                            <dependency>
                                                <groupId>org.hsqldb</groupId>
                                                <artifactId>hsqldb</artifactId>
                                            </dependency>
                                            <dependency>
                                                <groupId>javax.transaction</groupId>
                                                <artifactId>jta</artifactId>
                                            </dependency>
                                        </dependencies>
                                    </container>
                                    <configuration>
                                        <home>${project.build.directory}/${cargo.containerid}-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.jvmargs>
                                                ${crowdid.cargo.debug}
                                                -Dcrowd.openid.properties=${acceptanceTestClassDirectory}/localtest.crowdid.properties
                                                -Dcrowd.property.crowd.server.url=http://localhost:${crowd.cargo.servlet.port}/crowd
                                                -Dcrowd.property.application.login.url.template=http://localhost:8097/openidserver?returnToUrl=$${RETURN_TO_URL}
                                                -Dcrowd.property.application.base.url=http://localhost:${crowdid.cargo.servlet.port}/openidserver
                                                -Djava.awt.headless=true
                                            </cargo.jvmargs>
                                            <cargo.servlet.uriencoding>UTF-8</cargo.servlet.uriencoding>
                                            <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>
                                    </configuration>
                                    <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>${cargo.pingTimeout}</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>${cargo.pingTimeout}</pingTimeout>
                                        </deployable>
                                    </deployables>
                                </configuration>
                            </execution>

                            <execution>
                                <id>stop-crowdid-container</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                                <configuration>
                                    <skip>${maven.test.skip}</skip>
                                    <configuration>
                                        <home>${project.build.directory}/${cargo.containerid}-crowdid/container</home>
                                        <properties>
                                            <cargo.servlet.port>${crowdid.cargo.servlet.port}</cargo.servlet.port>
                                            <cargo.jvmargs>-Djava.awt.headless=true</cargo.jvmargs>
                                        </properties>
                                    </configuration>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- Runs Crowd remote directory (LDAP but not Crowd-to-Crowd sync) acceptance tests -->
            <id>remote-directory-acceptance-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <!-- 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>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- Runs Crowd REST API acceptance tests -->
            <id>rest-api-acceptance-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <!-- 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>
            </build>
        </profile>

        <profile>
            <!-- Runs Crowd SOAP API acceptance tests -->
            <id>soap-api-acceptance-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <!-- run Crowd SOAP API functional tests -->
                            <execution>
                                <id>test-crowd-soap</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>**/SoapAcceptanceTestHarness.java</include>
                                    </includes>
                                    <argLine>-Xmx256m</argLine>
                                    <skip>${maven.test.skip}</skip>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <!-- Start Crowd and run SetupCrowdTest, but don't run any other tests (those are in other profiles) -->
    <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-rest-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>
                                <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>org.hsqldb</groupId>
                                        <artifactId>hsqldb</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>org.postgresql</groupId>
                                        <artifactId>postgresql</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>net.sourceforge.jtds</groupId>
                                        <artifactId>jtds</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}/${cargo.containerid}-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.servlet.uriencoding>UTF-8</cargo.servlet.uriencoding>
                                    <cargo.jvmargs>${crowd.cargo.debug} -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dldap.server.port=${apacheds.ldap.port} -Dcrowd.home=${crowd.home} -Dapacheds.ldap.port=${apacheds.1.5.ldap.port} -Dcrowd.polling.startdelay=86400000 -Djava.awt.headless=true</cargo.jvmargs>
                                </properties>
                            </configuration>
                            <deployables>
                                <deployable>
                                    <groupId>com.atlassian.crowd</groupId>
                                    <artifactId>crowd-web-app</artifactId>
                                    <type>war</type>
                                    <properties>
                                        <context>crowd</context>
                                    </properties>
                                    <!-- ping a URL that is not Johnson-protected and returns HTTP 200 -->
                                    <pingURL>http://localhost:${crowd.cargo.servlet.port}/crowd/console/favicon.ico</pingURL>
                                    <pingTimeout>${cargo.pingTimeout}</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/style/main.css</pingURL>
                                    <pingTimeout>${cargo.pingTimeout}</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>${cargo.pingTimeout}</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>${cargo.pingTimeout}</pingTimeout>
                                </deployable>
                            </deployables>
                        </configuration>
                    </execution>

                    <execution>
                        <id>stop-crowd-container</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                        <configuration>
                            <skip>${crowd.setup.skip}</skip>
                            <configuration>
                                <home>${project.build.directory}/${cargo.containerid}-crowd/container</home>
                                <properties>
                                    <cargo.servlet.port>${crowd.cargo.servlet.port}</cargo.servlet.port>
                                    <cargo.jvmargs>-Djava.awt.headless=true</cargo.jvmargs>
                                </properties>
                            </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>
                        <systemProperties>
                            <property>
                                <name>acceptance.test.crowd.port</name>
                                <value>${crowd.cargo.servlet.port}</value>
                            </property>
                            <property>
                                <!-- not needed here, but needed for -Premote-crowd-acceptance-tests -->
                                <name>acceptance.test.crowd2.port</name>
                                <value>${crowd2.cargo.servlet.port}</value>
                            </property>
                            <property>
                                <name>acceptance.test.crowdid.port</name>
                                <value>${crowdid.cargo.servlet.port}</value>
                            </property>
                            <property>
                                <name>acceptance.test.crowdidclient.port</name>
                                <value>${crowdid.cargo.servlet.port}</value>
                            </property>
                            <property>
                                <name>acceptance.test.demo.port</name>
                                <value>${crowd.cargo.servlet.port}</value>
                            </property>
                            <property>
                                <name>crowd.property.crowd.server.url</name>
                                <value>http://localhost:${crowd.cargo.servlet.port}/crowd</value>
                            </property>
                        </systemProperties>

                        <!--<debugForkedProcess>true</debugForkedProcess>-->
                        <testClassesDirectory>${acceptanceTestClassDirectory}</testClassesDirectory>
                    </configuration>

                    <executions>

                        <!-- setup Crowd #1 -->
                        <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>

                        <!-- Other executions are added by other profiles -->

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