<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.atlassian.crowd</groupId>
        <artifactId>atlassian-crowd</artifactId>
        <version>2.10.1</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <artifactId>crowd-directory-test</artifactId>

    <name>Atlassian Crowd directory integration tests</name>

    <description>Integration testing against real LDAP servers.</description>

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

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

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

        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <scope>runtime</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>
        <acceptanceTestClassDirectory>${project.build.directory}/it-classes</acceptanceTestClassDirectory>

        <cargo.wait>false</cargo.wait>
        <cargo.pingTimeout>${cargo.timeout}</cargo.pingTimeout>

        <crowd.cargo.servlet.port>8095</crowd.cargo.servlet.port>
        <apacheds.ldap.port>11389</apacheds.ldap.port>
        <apacheds.1.5.ldap.port>12389</apacheds.1.5.ldap.port>

        <license.scope>test</license.scope>
    </properties>

    <profiles>
        <!-- LabManager profile -->
        <profile>
            <id>tpm</id>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <artifactId>maven-surefire-plugin</artifactId>

                            <configuration>
                                <!-- debugForkedProcess>true</debugForkedProcess -->

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

                            </configuration>

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

        <profile>
            <!-- Runs Crowd remote directory (LDAP but not Crowd-to-Crowd sync) acceptance tests -->
            <id>remote-directory-acceptance-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <executions>
                            <!-- run Crowd Remote Directory functional tests -->
                            <execution>
                                <id>test-crowddirectory</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <failIfNoTests>true</failIfNoTests>
                                    <includes>
                                        <include>**/CrowdDirectoryTestHarness.class</include>
                                    </includes>
                                    <argLine>-Xmx256m</argLine>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>

                <!-- skip unit tests -->
                <executions>
                    <execution>
                        <id>default-test</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <executions>
                    <!-- Crowd Container Apache DS 1.0 and 1.5-->
                    <execution>
                        <id>start-ldap-servers</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                            <wait>${cargo.wait}</wait>
                            <container>
                                <output>${project.build.directory}/output-crowd.log</output>
                                <log>${project.build.directory}/cargo-crowd.log</log>
                                <systemProperties>
                                    <ldap.server.example.ldif>${project.build.testOutputDirectory}/example.ldif</ldap.server.example.ldif>
                                    <ldap.server.port>${apacheds.ldap.port}</ldap.server.port>
                                    <apacheds.ldap.port>${apacheds.1.5.ldap.port}</apacheds.ldap.port>
                                </systemProperties>
                            </container>
                            <configuration>
                                <home>${project.build.directory}/${cargo.containerid}-crowd/container</home>
                                <properties>
                                    <cargo.servlet.port>${crowd.cargo.servlet.port}</cargo.servlet.port>
                                    <cargo.servlet.uriencoding>UTF-8</cargo.servlet.uriencoding>
                                    <cargo.jvmargs>-Xms128m -Xmx512m -Djava.awt.headless=true</cargo.jvmargs>
                                </properties>
                            </configuration>
                            <deployables>
                                <deployable>
                                    <groupId>com.atlassian.ldap</groupId>
                                    <artifactId>atlassian-ldap-test-webapp</artifactId>
                                    <type>war</type>
                                    <properties>
                                        <context>apacheds</context>
                                    </properties>
                                    <pingTimeout>${cargo.pingTimeout}</pingTimeout>
                                </deployable>
                                <deployable>
                                    <groupId>com.atlassian.crowd</groupId>
                                    <artifactId>crowd-apacheds-server</artifactId>
                                    <type>war</type>
                                    <properties>
                                        <context>apacheds15</context>
                                    </properties>
                                    <pingTimeout>${cargo.pingTimeout}</pingTimeout>
                                </deployable>
                            </deployables>
                        </configuration>
                    </execution>

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

            </plugin>
        </plugins>
    </build>
</project>
