<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.confluence.test</groupId>
        <artifactId>confluence-test-runner</artifactId>
        <version>4.1.9-studio-1</version>
    </parent>

    <artifactId>confluence-crowd-test</artifactId>
    <packaging>jar</packaging>

    <name>Confluence Crowd Acceptance Test Runner</name>
    <description>This module runs all acceptance tests against a Confluence instance configured with Crowd.
    </description>

    <build>
        <testSourceDirectory>src/it/java</testSourceDirectory>
        <testResources>
            <testResource>
                <directory>src/it/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
    </build>

    <profiles>
        <profile>
            <id>crowd</id>
            <dependencies>
                <dependency>
                    <groupId>com.atlassian.crowd</groupId>
                    <artifactId>crowd-web-app</artifactId>
                    <version>${crowd.version}</version>
                    <type>war</type>
                </dependency>
                <!-- These are runtime dependencies of crowd, so they aren't supplied automatically. -->
                <dependency>
                    <groupId>javax.transaction</groupId>
                    <artifactId>jta</artifactId>
                </dependency>
                <dependency>
                    <groupId>javax.activation</groupId>
                    <artifactId>activation</artifactId>
                </dependency>
                <dependency>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </dependency>
                <dependency>
                    <groupId>org.hsqldb</groupId>
                    <artifactId>hsqldb</artifactId>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <!--
                        Use the dependency plugin to
                         - extract the Confluence acceptance tests
                           into the test output directory for running with the Crowd-specific tests
                         - extract the Crowd web app so that its properties can be changed.
                        -->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.0-alpha-4</version>
                        <executions>
                            <execution>
                                <id>unpack-crowd-war</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>com.atlassian.crowd</groupId>
                                            <artifactId>crowd-web-app</artifactId>
                                            <!-- hopefully figured out from dependency?  -->
                                            <type>war</type>
                                        </artifactItem>
                                    </artifactItems>
                                    <outputDirectory>${project.build.testOutputDirectory}/crowd-webapp-unpacked
                                    </outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>unpack-confluence-war</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>unpack-dependencies</goal>
                                </goals>
                                <configuration>
                                    <includeArtifactIds>confluence-webapp</includeArtifactIds>
                                    <outputDirectory>${project.build.testOutputDirectory}/confluence-webapp-unpacked
                                    </outputDirectory>
                                </configuration>
                            </execution>
                         </executions>
                    </plugin>
                    <plugin>
                        <!--
                        Configure Surefire to run in the integration-test phase, but not in the
                         normal test phase.
                        -->
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <!-- skip unit tests -->
                            <skip>true</skip>
                            <systemProperties combine.children="append">
                                <property>
                                    <name>crowd.url</name>
                                    <value>${crowd.url}</value>
                                </property>
                                <property>
                                    <name>crowd.confluence.application.name</name>
                                    <value>${crowd.confluence.application.name}</value>
                                </property>
                                <property>
                                    <name>crowd.confluence.application.password</name>
                                    <value>${crowd.confluence.application.password}</value>
                                </property>
                                <property>
                                    <name>crowdMode</name>
                                    <value>true</value>
                                </property>
                                <property>
                                    <name>ldapMode</name>
                                    <value>CROWD</value>
                                </property>
                            </systemProperties>
                        </configuration>
                        <executions>
                            <execution>
                                <id>setup-crowd</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>**/SetupCrowdTest.java</include>
                                    </includes>
                                    <skip>false</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>confluence-setup-inside-crowd</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>**/SetupConfluenceInsideCrowd.java</include>
                                    </includes>
                                    <skip>false</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>setup-confluence</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>**/SetupAcceptanceTest.java</include>
                                    </includes>
                                    <skip>false</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>test-confluence</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/confluence/*AcceptanceTest.java</include>
                                        <include>com/atlassian/confluence/rest/*AcceptanceTest.java</include>
                                        <include>com/atlassian/confluence/dashboard/**/*.java</include>
                                        <include>com/atlassian/confluence/multimedia/**/*.java</include>
                                        <include>com/atlassian/confluence/gadgets/**/*.java</include>
                                    </includes>
                                    <excludes>
                                        <exclude>com/atlassian/confluence/Abstract*.java</exclude>
                                        <exclude>com/atlassian/confluence/KnownBugsAcceptanceTest.java</exclude>
                                        <!-- excluded until CWD-395 CWD-396 are fixed -->
                                        <exclude>com/atlassian/confluence/UserPickerAcceptanceTest.java</exclude>
                                        <exclude>com/atlassian/confluence/GroupPickerAcceptanceTest.java</exclude>
                                        <!-- testing out of memory issue -->
                                        <exclude>com/atlassian/confluence/MacrosAcceptanceTest</exclude>
                                        <!--
                                          Testing that administrator permissions are migrated when backup is imported.
                                          It relies on the fact that users are imported into a currently configured user repository.
                                          This is not the case when we use crowd user repository.
                                        -->
                                        <exclude>
                                            com/atlassian/confluence/ConvertAdministerConfluenceToSystemAdministratorAcceptanceTest.java
                                        </exclude>
                                        <!--
                                         Test disabled as this test imports non-standard users.
                                         User creation from backup into crowd does not work in this build.
                                         This test works in the embedded crowd branch.
                                        -->
                                        <exclude>com/atlassian/confluence/NotificationImportAcceptanceTest.java
                                        </exclude>

                                        <!-- CONFDEV-3463 -->
                                        <exclude>com/atlassian/confluence/Ldap*AcceptanceTest.java</exclude>
                                        <exclude>com/atlassian/confluence/DelegatedLdap*AcceptanceTest.java</exclude>
                                        <exclude>com/atlassian/confluence/DirectoryOrderAcceptanceTest.java</exclude>
                                    </excludes>
                                    <skip>false</skip>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-crowd-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                                <configuration>
                                    <wait>${cargo.crowd.wait}</wait>
                                    <container>
                                        <containerId>tomcat5x</containerId>
                                        <zipUrlInstaller>
                                            <url>${tomcat5.url}</url>
                                            <installDir>${cargo.container.zipurlinstaller.installdir}</installDir>
                                        </zipUrlInstaller>
                                        <timeout>120000</timeout>
                                        <output>${project.build.directory}/output-crowd.log</output>
                                        <log>${project.build.directory}/cargo-crowd.log</log>
                                        <systemProperties>
                                            <crowd.home>${project.build.directory}/crowd-home</crowd.home>
                                        </systemProperties>
                                        <dependencies>
                                            <!-- These 4 are runtime dependencies of crowd,
                                                 so they aren't supplied automatically. -->
                                            <dependency>
                                                <groupId>org.hsqldb</groupId>
                                                <artifactId>hsqldb</artifactId>
                                            </dependency>
                                            <dependency>
                                                <groupId>javax.transaction</groupId>
                                                <artifactId>jta</artifactId>
                                            </dependency>
                                            <dependency>
                                                <groupId>javax.activation</groupId>
                                                <artifactId>activation</artifactId>
                                            </dependency>
                                            <dependency>
                                                <groupId>javax.mail</groupId>
                                                <artifactId>mail</artifactId>
                                            </dependency>
                                        </dependencies>
                                    </container>
                                    <configuration>
                                        <home>${project.build.directory}/tomcat5x-crowd/container</home>
                                        <properties>
                                            <cargo.servlet.port>${cargo.crowd.servlet.port}</cargo.servlet.port>
                                            <cargo.rmi.port>${cargo.crowd.rmi.port}</cargo.rmi.port>
                                            <cargo.jvmargs>-XX:MaxPermSize=128M -Djava.awt.headless=true -Xmx256m
                                            </cargo.jvmargs>
                                            <cargo.datasource.datasource>
                                                cargo.datasource.url=jdbc:hsqldb:${project.build.directory}/database/crowddb|
                                                cargo.datasource.driver=org.hsqldb.jdbcDriver|
                                                cargo.datasource.username=sa|
                                                cargo.datasource.password=|
                                                cargo.datasource.type=javax.sql.DataSource|
                                                cargo.datasource.jndi=jdbc/CrowdDS
                                            </cargo.datasource.datasource>
                                        </properties>
                                        <deployables>
                                            <deployable>
                                                <groupId>com.atlassian.crowd</groupId>
                                                <artifactId>crowd-web-app</artifactId>
                                                <type>war</type>
                                                <properties>
                                                    <context>crowd</context>
                                                </properties>
                                                <location>${project.build.testOutputDirectory}/crowd-webapp-unpacked
                                                </location>
                                                <pingURL>http://localhost:${cargo.crowd.servlet.port}/crowd</pingURL>
                                                <pingTimeout>240000</pingTimeout>
                                            </deployable>
                                        </deployables>
                                    </configuration>
                                </configuration>
                            </execution>
                            <execution>
                                <id>start-confluence-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                                <configuration>
                                    <wait>${cargo.confluence.wait}</wait>
                                    <container>
                                        <containerId>tomcat5x</containerId>
                                        <zipUrlInstaller>
                                            <url>${tomcat5.url}</url>
                                            <installDir>${cargo.container.zipurlinstaller.installdir}</installDir>
                                        </zipUrlInstaller>
                                        <timeout>120000</timeout>
                                        <output>${project.build.directory}/output-confluence.log</output>
                                        <log>${project.build.directory}/cargo-confluence.log</log>
                                        <systemProperties>
                                            <confluence.home>${project.build.directory}/confluence-home
                                            </confluence.home>
                                        </systemProperties>
                                    </container>
                                    <configuration>
                                        <home>${project.build.directory}/tomcat5x-confluence/container</home>
                                        <properties>
                                            <cargo.servlet.port>${http.port}</cargo.servlet.port>
                                            <cargo.rmi.port>${controller.port}</cargo.rmi.port>
                                            <cargo.jvmargs>${jvm.args}</cargo.jvmargs>
                                        </properties>
                                        <deployables>
                                            <deployable>
                                                <groupId>com.atlassian.confluence</groupId>
                                                <artifactId>confluence-webapp</artifactId>
                                                <type>war</type>
                                                <properties>
                                                    <context>${webappContext}</context>
                                                </properties>
                                                <location>
                                                    ${project.build.testOutputDirectory}/confluence-webapp-unpacked
                                                </location>
                                                <pingURL>http://localhost:${http.port}/crowd</pingURL>
                                                <pingTimeout>240000</pingTimeout>
                                            </deployable>
                                        </deployables>
                                    </configuration>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <!-- activates the maven clean plugin configuration from the parent -->
                        <artifactId>maven-clean-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <!-- URLs & ports -->
                <cargo.crowd.servlet.port>${http.port2}</cargo.crowd.servlet.port>
                <cargo.crowd.rmi.port>${controller.port2}</cargo.crowd.rmi.port>
                <crowd.url>http://localhost:${cargo.crowd.servlet.port}/crowd</crowd.url>

                <!-- Crowd configuration -->
                <crowd.confluence.application.name>confluence</crowd.confluence.application.name>
                <crowd.confluence.application.password>password</crowd.confluence.application.password>

                <cargo.crowd.wait>false</cargo.crowd.wait>
                <cargo.confluence.wait>false</cargo.confluence.wait>
                <unpack.stuff>true</unpack.stuff>
            </properties>
        </profile>
    </profiles>

</project>

