<?xml version="1.0" encoding="UTF-8"?>
<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>3.1.5</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>
        <module>crowd-testkit-plugin</module>
        <module>crowd-web-load-test</module>
        <module>crowd-functest-plugin</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-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.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>
            <exclusions>
                <!-- gatling in web-load-tests uses a different scala version than openid in bundled-apps tests-->
                <exclusion>
                    <groupId>com.atlassian.crowd</groupId>
                    <artifactId>crowd-openid-spray-acceptance-test</artifactId>
                </exclusion>

                <!-- gatling in web-load-tests uses a different netty version than mockserver in cluster tests -->
                <exclusion>
                    <groupId>org.mock-server</groupId>
                    <artifactId>mockserver-netty</artifactId>
                </exclusion>

                <!-- gatling in web-load-tests uses a different netty version than littleproxy -->
                <exclusion>
                    <groupId>com.github.ganskef</groupId>
                    <artifactId>littleproxy-mitm</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

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

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

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

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowd-functest-plugin</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>com.atlassian.functest</groupId>
            <artifactId>functest-plugin</artifactId>
        </dependency>

        <dependency>
            <groupId>com.atlassian.labs.plugins</groupId>
            <artifactId>quickreload</artifactId>
        </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>

        <crowdid.cargo.goal>start</crowdid.cargo.goal>
        <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 -->
        <maven.test.skip>false</maven.test.skip>
        <crowd.setup.skip>${maven.test.skip}</crowd.setup.skip>
        <crowd2.setup.skip>true</crowd2.setup.skip>
        <crowd.setup.test.skip>${crowd.setup.skip}</crowd.setup.test.skip>

        <!-- please list ALL port configurations here -->
        <crowd.cargo.servlet.port>8095</crowd.cargo.servlet.port>
        <crowd.cargo.rmi.port>8195</crowd.cargo.rmi.port>
        <crowd.cargo.ajp.port>8009</crowd.cargo.ajp.port>
        <crowd.cargo.debug /> <!-- set in the debug profile if activated -->
        <crowd.cargo.suspend>n</crowd.cargo.suspend>
        <crowd2.cargo.servlet.port>8096</crowd2.cargo.servlet.port>
        <crowd2.cargo.rmi.port>8196</crowd2.cargo.rmi.port>
        <crowd2.cargo.ajp.port>8010</crowd2.cargo.ajp.port>
        <crowd2.cargo.debug />
        <crowdid.cargo.servlet.port>8097</crowdid.cargo.servlet.port>
        <crowdid.cargo.rmi.port>8197</crowdid.cargo.rmi.port>
        <crowdid.cargo.ajp.port>8011</crowdid.cargo.ajp.port>
        <crowdid.cargo.debug />
        <apacheds.1.5.ldap.port>12389</apacheds.1.5.ldap.port>

        <!-- Configure logging to files as default, but in practice this is usually overridden by -Pstdout-logging -->
        <crowd.cargo.output>${project.build.directory}/output-crowd.log</crowd.cargo.output>
        <crowd.cargo.log>${project.build.directory}/cargo-crowd.log</crowd.cargo.log>
        <crowd2.cargo.output>${project.build.directory}/output-crowd2.log</crowd2.cargo.output>
        <crowd2.cargo.log>${project.build.directory}/cargo-crowd2.log</crowd2.cargo.log>
        <crowdid.cargo.output>${project.build.directory}/output-crowdid.log</crowdid.cargo.output>
        <crowdid.cargo.log>${project.build.directory}/cargo-crowdid.log</crowdid.cargo.log>

        <!-- 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 />

        <xvfb.enable>false</xvfb.enable>
        <xvfb.display>:0</xvfb.display>

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

        <docker.skip>true</docker.skip>
        <docker.postgres.skip>true</docker.postgres.skip>
        <docker.openldap.skip>true</docker.openldap.skip>
        <openldap.ldif.dir>${basedir}/src/test/conf/openldap/small</openldap.ldif.dir>

        <crowd.node.urls />
    </properties>


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

        <profile>
            <id>suspend</id>
            <properties>
                <crowd.cargo.suspend>y</crowd.cargo.suspend>
            </properties>
        </profile>

        <profile>
            <id>stdout-logging</id>
            <activation>
                <!-- Enable for convenience; running tests requires explicit profile which will turn this off anyway -->
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <!-- Log Tomcats' output and deployed applications' logs to stdout -->
                <crowd.cargo.output />
                <crowd.cargo.log />
                <crowd2.cargo.output />
                <crowd2.cargo.log />
                <crowdid.cargo.output />
                <crowdid.cargo.log />
            </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>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>test-crowd-selenium</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/crowd/selenium/tests/console/**/*.java</include>
                                    </includes>
                                    <skip>${selenium.test.skip}</skip>
                                    <systemPropertyVariables>
                                        <selenium.server.location>${selenium.server.location}</selenium.server.location>
                                        <selenium.port>${selenium.server.port}</selenium.port>
                                        <selenium.browser>${selenium.browser}</selenium.browser>
                                        <selenium.max.wait.time>${selenium.max.wait.time}</selenium.max.wait.time>
                                    </systemPropertyVariables>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- LabManager profile for load testing -->
        <profile>
            <id>tpm-loadTest10k</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>

                        <configuration>
                            <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>integration-test</goal>
                                </goals>
                                <configuration>
                                    <includes>
                                        <include>**/SetupCrowdWithDatabase.java</include>
                                    </includes>
                                </configuration>
                            </execution>

                            <!-- Run load tests for AD2K3 -->
                            <execution>
                                <id>loadtest-ad2k3</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/crowd/acceptance/tests/directory/**/*.java</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.gmaven</groupId>
                        <artifactId>groovy-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>upload-results-to-statsd</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <properties>
                                        <path>.*test-stats.csv</path>
                                        <prefix>crowd.ci.timings.loadtest</prefix>
                                    </properties>
                                    <source>${project.basedir}/src/test/bin/saveStats.groovy</source>
                                </configuration>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>com.datadoghq</groupId>
                                <artifactId>java-dogstatsd-client</artifactId>
                                <version>2.3</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>tpm-openldap</id>
            <properties>
                <docker.openldap.skip>false</docker.openldap.skip>
                <openldap.ldif.dir>${basedir}/src/test/conf/openldap/large</openldap.ldif.dir>
                <openldap.port>11389</openldap.port>
            </properties>
        </profile>

        <!-- profile for running Java-based performance tests that don't need external LDAP servers -->
        <profile>
            <id>performance</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>

                        <executions>
                            <!-- run performance tests -->
                            <execution>
                                <id>test-performance</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/crowd/acceptance/tests/load/**/*.java</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
            </plugins>
            </build>
        </profile>

        <profile>
            <!-- Runs Crowd (the web-app) console acceptance tests -->
            <id>web-app-console-acceptance-tests</id>
            <properties>
                <xvfb.enable>true</xvfb.enable>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <!-- run Crowd functional tests -->
                            <execution>
                                <id>test-crowd</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/crowd/acceptance/tests/applications/crowd/**/*.java</include>
                                        <include>com/atlassian/crowd/acceptance/tests/administration/**/*.java</include>
                                        <include>com/atlassian/crowd/acceptance/tests/decorator/**/*.java</include>
                                    </includes>
                                    <systemProperties>
                                        <property>
                                            <name>xvfb.enable</name>
                                            <value>${xvfb.enable}</value>
                                        </property>
                                        <property>
                                            <name>xvfb.display</name>
                                            <value>${xvfb.display}</value>
                                        </property>
                                        <property>
                                            <name>crowd.node.urls</name>
                                            <value>${crowd.node.urls}</value>
                                        </property>
                                    </systemProperties>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>com.github.ganskef</groupId>
                    <artifactId>littleproxy-mitm</artifactId>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <!-- Starts CrowdID and runs bundled Crowd OpenID acceptance tests -->
            <id>bundled-apps-acceptance-tests</id>
            <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-openid-spray-acceptance-test</artifactId>
                                            <version>${project.version}</version>
                                        </artifactItem>
                                    </artifactItems>
                                    <outputDirectory>${acceptanceTestClassDirectory}</outputDirectory>
                                </configuration>

                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <!-- run CrowdID functional tests -->
                            <execution>
                                <id>test-crowdid</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/crowd/acceptance/tests/applications/crowdid/**/*.java</include>
                                        <include>com/atlassian/crowd/acceptance/applications/crowdid/server/spray/**/*.scala</include>
                                    </includes>
                                    <systemPropertyVariables>
                                        <crowd.property.application.login.url>http://localhost:${crowdid.cargo.servlet.port}/openidserver</crowd.property.application.login.url>
                                    </systemPropertyVariables>
                                </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>${crowdid.cargo.goal}</goal>
                                </goals>
                                <configuration>
                                    <skip>${maven.test.skip}</skip>
                                    <container>
                                        <output>${crowdid.cargo.output}</output>
                                        <log>${crowdid.cargo.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.tomcat.ajp.port>${crowdid.cargo.ajp.port}</cargo.tomcat.ajp.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.tomcat.uriencoding>UTF-8</cargo.tomcat.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.jndi=jdbc/CrowdIDDS|
                                                cargo.datasource.properties=validationQuery=SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS
                                            </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.tomcat.ajp.port>${crowdid.cargo.ajp.port}</cargo.tomcat.ajp.port>
                                            <cargo.jvmargs>-Djava.awt.headless=true</cargo.jvmargs>
                                        </properties>
                                    </configuration>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>com.atlassian.crowd</groupId>
                    <artifactId>crowd-openid-spray-acceptance-test</artifactId>
                    <version>${project.version}</version>
                </dependency>
            </dependencies>
        </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-failsafe-plugin</artifactId>
                        <executions>
                            <!-- run Crowd REST API functional tests -->
                            <execution>
                                <id>test-crowd-admin</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/crowd/acceptance/tests/rest/**/*.java</include>
                                    </includes>
                                </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-failsafe-plugin</artifactId>
                        <executions>
                            <!-- run Crowd SOAP API functional tests -->
                            <execution>
                                <id>test-crowd-soap</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/crowd/acceptance/tests/soap/**/*.java</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- launch 2 nodes connected to a shared postgres db -->
            <id>cluster</id>
            <properties>
                <docker.skip>false</docker.skip>
                <docker.postgres.skip>false</docker.postgres.skip>
                <docker.openldap.skip>false</docker.openldap.skip>

                <crowd2.setup.skip>false</crowd2.setup.skip>
                <crowd.setup.test.skip>true</crowd.setup.test.skip>
                <crowd.node.urls>http://localhost:${crowd.cargo.servlet.port}/crowd,http://localhost:${crowd2.cargo.servlet.port}/crowd</crowd.node.urls>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-node1-config-files</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>pre-integration-test</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/test/conf/cluster-crowd-home</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${crowd.home}</outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-node2-config-files</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>pre-integration-test</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/test/conf/cluster-crowd-home</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${crowd2.home}</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <!-- node1 gets testkit from the 'copy-test-plugins' execution -->
                            <execution>
                                <id>copy-node2-plugins</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>com.atlassian.crowd</groupId>
                                            <artifactId>crowd-testkit-plugin</artifactId>
                                            <version>${project.version}</version>
                                            <type>jar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${crowd2.home}/shared/plugins</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>functest</id>
            <properties>
                <!-- use a pre-setup hsql crowd home -->
                <crowd2.home>${crowd.home}</crowd2.home>
                <crowd2.cargo.servlet.port>${crowd.cargo.servlet.port}</crowd2.cargo.servlet.port>
                <crowd.setup.test.skip>true</crowd.setup.test.skip>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-functest-crowd-config-files</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>pre-integration-test</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/test/conf/crowd-home-hsql</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${crowd.home}</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-functest-plugins</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <includeArtifactIds>functest-plugin, crowd-functest-plugin</includeArtifactIds>
                                    <outputDirectory>${crowd.home}/shared/plugins</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>cluster-functest-plugin-tests</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/crowd/acceptance/tests/functest/**/*.java</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- Runs Crowd cluster acceptance tests, only makes sense with -Pcluster -->
            <id>cluster-acceptance-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>cluster-acceptance-tests</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/crowd/acceptance/tests/cluster/**/*.java</include>
                                    </includes>
                                    <systemPropertyVariables>
                                        <crowd.node.urls>${crowd.node.urls}</crowd.node.urls>
                                        <openldap.port>${openldap.port}</openldap.port>
                                    </systemPropertyVariables>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>org.mock-server</groupId>
                    <artifactId>mockserver-netty</artifactId>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>postgres</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-crowd-config-files</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>pre-integration-test</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/test/conf/crowd-home-postgres</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${crowd.home}</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <docker.skip>false</docker.skip>
                <docker.postgres.skip>false</docker.postgres.skip>
                <crowd.setup.test.skip>true</crowd.setup.test.skip>
            </properties>
        </profile>
        <profile>
            <id>remote-crowd-acceptance-tests</id>
            <properties>
                <crowd2.setup.skip>false</crowd2.setup.skip>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <!-- Crowd #1 is setup by the main pom (w/o any profile) -->

                            <!-- then setup Crowd #2 -->
                            <execution>
                                <id>copy-crowd2-config-files</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>pre-integration-test</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/test/conf/crowd-home-hsql</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${crowd2.home}</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <!--Runs the Crowd-to-Crowd tests.-->
                        <executions>
                            <execution>
                                <id>test-remote-crowd</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/crowd/acceptance/tests/synchronisation/remote/**/*.java</include>
                                    </includes>
                                    <argLine>-Xmx512m -Dcrowd.home=${crowd.home}</argLine>
                                    <skip>${maven.test.skip}</skip>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>crowd-web-load-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.gatling</groupId>
                        <artifactId>gatling-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>run-gatling-tests</id>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <phase>integration-test</phase>

                                <configuration>
                                    <simulationsFolder>crowd-web-load-test/src/test/scala</simulationsFolder>
                                    <configFolder>crowd-web-load-test/src/test/resources</configFolder>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.gmaven</groupId>
                        <artifactId>groovy-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>upload-results-to-statsd</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <properties>
                                        <path>.*simulation.log</path>
                                        <prefix>crowd.ci.webloadtest</prefix>
                                        <parser>gatling</parser>
                                    </properties>
                                    <source>${project.basedir}/src/test/bin/saveStats.groovy</source>
                                </configuration>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>com.datadoghq</groupId>
                                <artifactId>java-dogstatsd-client</artifactId>
                                <version>2.3</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>zip-gatling-reports</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/gatling</outputDirectory>
                                    <descriptors>
                                        <descriptor>crowd-web-load-test/src/main/assembly/gatling-reports.xml</descriptor>
                                    </descriptors>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>com.atlassian.crowd</groupId>
                    <artifactId>crowd-web-load-test</artifactId>
                    <version>${project.version}</version>
                </dependency>

                <dependency>
                    <groupId>com.typesafe.akka</groupId>
                    <artifactId>akka-actor_${scala.major.version}</artifactId>
                    <version>2.4.12</version>
                </dependency>

                <dependency>
                    <groupId>com.typesafe.akka</groupId>
                    <artifactId>akka-slf4j_${scala.major.version}</artifactId>
                    <version>2.4.12</version>
                </dependency>

                <dependency>
                    <groupId>org.scala-lang</groupId>
                    <artifactId>scala-library</artifactId>
                    <version>2.11.8</version>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>maven-cargo-crowdid-wait</id>
            <activation>
                <property>
                    <name>cargo.wait.crowdid</name>
                    <value>true</value>
                </property>
            </activation>
            <properties>
                <crowdid.cargo.goal>run</crowdid.cargo.goal>
            </properties>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <configuration>
                    <images>
                        <image>
                            <alias>dc-postgres</alias>
                            <name>postgres:9.5</name>

                            <run>
                                <skip>${docker.postgres.skip}</skip>
                                <ports>
                                    <port>db.port:5432</port>
                                </ports>
                                <env>
                                    <POSTGRES_DB>crowd</POSTGRES_DB>
                                    <POSTGRES_USER>crowd</POSTGRES_USER>
                                    <POSTGRES_PASSWORD>crowd</POSTGRES_PASSWORD>
                                </env>
                                <volumes>
                                    <bind>
                                        <volume>${basedir}/src/test/conf/basic-crowd-db:/docker-entrypoint-initdb.d</volume>
                                    </bind>
                                </volumes>
                                <wait>
                                    <log>PostgreSQL init process complete</log>
                                    <time>1200000</time>
                                </wait>
                                <log>
                                    <prefix>postgres</prefix>
                                </log>
                                <namingStrategy>alias</namingStrategy>
                            </run>
                        </image>
                        <image>
                            <alias>dc-openldap</alias>
                            <name>dinkel/openldap</name>

                            <run>
                                <skip>${docker.openldap.skip}</skip>
                                <ports>
                                    <port>openldap.port:389</port>
                                </ports>
                                <env>
                                    <SLAPD_PASSWORD>admin</SLAPD_PASSWORD>
                                    <SLAPD_DOMAIN>example.com</SLAPD_DOMAIN>
                                </env>
                                <volumes>
                                    <bind>
                                        <volume>${openldap.ldif.dir}:/etc/ldap.dist/prepopulate</volume>
                                    </bind>
                                </volumes>
                                <wait>
                                    <log>slapd starting</log>
                                    <time>1200000</time>
                                </wait>
                                <log>
                                    <prefix>openldap</prefix>
                                </log>
                                <namingStrategy>alias</namingStrategy>
                            </run>
                        </image>
                    </images>
                </configuration>
                <executions>
                    <execution>
                        <id>start</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

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

                            <outputDirectory>${acceptanceTestClassDirectory}</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-test-plugins</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeArtifactIds>crowd-decorator-test-plugin,crowd-testkit-plugin,quickreload</includeArtifactIds>
                            <outputDirectory>${crowd.home}/shared/plugins</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <!-- this is here to make sure it's executed before cargo in pre-integration-test -->
                <artifactId>maven-resources-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <executions>

                    <!-- Crowd #2, skipped unless crowd2.setup.skip set to false, non-blocking so needs to start first -->
                    <execution>
                        <id>start-crowd2-container</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                            <skip>${crowd2.setup.skip}</skip>
                            <container>
                                <output>${crowd2.cargo.output}</output>
                                <log>${crowd2.cargo.log}</log>
                                <dependencies>
                                    <dependency>
                                        <groupId>org.hsqldb</groupId>
                                        <artifactId>hsqldb</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>org.postgresql</groupId>
                                        <artifactId>postgresql</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.tomcat.ajp.port>${crowd2.cargo.ajp.port}</cargo.tomcat.ajp.port>
                                    <cargo.tomcat.uriencoding>UTF-8</cargo.tomcat.uriencoding>
                                    <cargo.jvmargs>${crowd2.cargo.debug} -Xms128m -Xmx1024m -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>${crowd2.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.tomcat.ajp.port>${crowd2.cargo.ajp.port}</cargo.tomcat.ajp.port>
                                    <cargo.jvmargs>-Djava.awt.headless=true</cargo.jvmargs>
                                </properties>
                            </configuration>
                        </configuration>
                    </execution>

                    <!-- Crowd Container (crowd web-app / security server) + Apache DS -->
                    <execution>
                        <id>start-crowd-container</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>${crowd.cargo.goal}</goal>
                        </goals>
                        <configuration>
                            <skip>${crowd.setup.skip}</skip>
                            <container>
                                <output>${crowd.cargo.output}</output>
                                <log>${crowd.cargo.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>

                                <configfiles>
                                    <configfile>
                                        <file>${basedir}/src/test/conf/server.xml</file>
                                        <todir>conf/</todir>
                                        <tofile>server.xml</tofile>
                                        <configfile>true</configfile>
                                        <overwrite>true</overwrite>
                                    </configfile>
                                </configfiles>

                                <properties>
                                    <!-- These must match the provided server.xml -->
                                    <cargo.servlet.port>${crowd.cargo.servlet.port}</cargo.servlet.port>
                                    <cargo.rmi.port>${crowd.cargo.rmi.port}</cargo.rmi.port>
                                    <cargo.tomcat.ajp.port>${crowd.cargo.ajp.port}</cargo.tomcat.ajp.port>

                                    <cargo.jvmargs>${crowd.cargo.debug} -Xms128m -Xmx1024m -Dcrowd.home=${crowd.home} -Dapacheds.ldap.port=${apacheds.1.5.ldap.port} -Dcrowd.polling.startdelay=86400000 -Djava.awt.headless=true -Dcluster.node.name=buzz</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-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.tomcat.ajp.port>${crowd.cargo.ajp.port}</cargo.tomcat.ajp.port>
                                    <cargo.jvmargs>-Djava.awt.headless=true</cargo.jvmargs>
                                </properties>
                            </configuration>
                        </configuration>
                    </execution>
                </executions>

            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-failsafe-plugin</artifactId>

                    <configuration>
                        <testClassesDirectory>${acceptanceTestClassDirectory}</testClassesDirectory>
                        <systemPropertyVariables>
                            <acceptance.test.crowd.port>${crowd.cargo.servlet.port}</acceptance.test.crowd.port>
                            <acceptance.test.crowd2.port>${crowd2.cargo.servlet.port}</acceptance.test.crowd2.port>
                            <acceptance.test.crowdid.port>${crowdid.cargo.servlet.port}</acceptance.test.crowdid.port>
                            <acceptance.test.crowdidclient.port>${crowdid.cargo.servlet.port}</acceptance.test.crowdidclient.port>
                            <crowd.property.crowd.server.url>http://localhost:${crowd.cargo.servlet.port}/crowd</crowd.property.crowd.server.url>
                            <crowd.url>${crowd.url}</crowd.url>
                            <crowd.home>${crowd.home}</crowd.home>
                        </systemPropertyVariables>
                    </configuration>

                    <executions>

                        <!-- setup Crowd #1 -->
                        <execution>
                            <id>setup-crowd</id>
                            <goals>
                                <goal>integration-test</goal>
                            </goals>
                            <phase>integration-test</phase>
                            <configuration>
                                <includes>
                                    <include>**/SetupCrowdTest.java</include>
                                </includes>
                                <argLine>-Xmx128m</argLine>
                                <skip>${crowd.setup.test.skip}</skip>
                            </configuration>
                        </execution>

                        <!-- Other executions are added by other profiles -->
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
