<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.distribution</groupId>
        <artifactId>crowd-distribution</artifactId>
        <version>3.1.2-m01-KRAK-453-1</version>
    </parent>

    <artifactId>crowd-plugin-test-resources</artifactId>
    <name>Atlassian Crowd Plugin Test Resources</name>
    <packaging>pom</packaging>
    <dependencies>

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowd-web-app</artifactId>
            <type>war</type>
        </dependency>

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

        <!-- JWebUnit dependencies -->
        <dependency>
            <groupId>net.sourceforge.jwebunit</groupId>
            <artifactId>jwebunit-core</artifactId>
            <scope>test</scope>
        </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>org.slf4j</groupId>
            <artifactId>slf4j-nop</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <crowd.home>${project.build.directory}/crowd-home</crowd.home>
        <acceptanceTestClassDirectory>${project.build.directory}/it-classes</acceptanceTestClassDirectory>

        <!-- please list ALL port configurations here -->
        <crowd.testresource.cargo.servlet.port>4990</crowd.testresource.cargo.servlet.port>
        <crowd.testresource.cargo.rmi.port>4991</crowd.testresource.cargo.rmi.port>
        <license.scope>test</license.scope>

        <!-- xvfb for setup test -->
        <xvfb.enable>true</xvfb.enable>
        <xvfb.display>:0</xvfb.display>
    </properties>

    <build>
        <finalName>crowd-plugin-test-resources</finalName>

        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-func-tests</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>

                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.atlassian.crowd</groupId>
                                    <artifactId>crowd-acceptance-test</artifactId>
                                    <version>${project.version}</version>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${acceptanceTestClassDirectory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <executions>
                    <execution>
                        <id>start-crowd-container</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>${crowd.cargo.goal}</goal>
                        </goals>
                        <configuration>
                            <skip>false</skip>
                            <container>
                                <containerId>${cargo.containerid}</containerId>
                                <output>${project.build.directory}/output-crowd.log</output>
                                <log>${project.build.directory}/cargo-crowd.log</log>
                                <systemProperties>
                                    <ldap.server.example.ldif>${acceptanceTestClassDirectory}/example.ldif</ldap.server.example.ldif>
                                </systemProperties>
                                <dependencies>
                                    <dependency>
                                        <groupId>org.hsqldb</groupId>
                                        <artifactId>hsqldb</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>org.postgresql</groupId>
                                        <artifactId>postgresql</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>javax.transaction</groupId>
                                        <artifactId>jta</artifactId>
                                    </dependency>
                                    <dependency>
                                        <groupId>javax.mail</groupId>
                                        <artifactId>mail</artifactId>
                                    </dependency>
                                </dependencies>
                            </container>
                            <configuration>
                                <home>${project.build.directory}/${cargo.containerid}-crowd/container</home>
                                <properties>
                                    <cargo.servlet.port>${crowd.testresource.cargo.servlet.port}</cargo.servlet.port>
                                    <cargo.rmi.port>${crowd.testresource.cargo.rmi.port}</cargo.rmi.port>
                                    <cargo.jvmargs>-Xms128m -Xmx512m -Dcrowd.home=${crowd.home} -Dcrowd.property.crowd.server.url=http://localhost:${crowd.testresource.cargo.servlet.port}/crowd/services/ -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>
                                    <pingURL>http://localhost:${crowd.testresource.cargo.servlet.port}/crowd/console/favicon.ico</pingURL>
                                    <pingTimeout>240000</pingTimeout>
                                </deployable>
                            </deployables>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop-crowd-container</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                        <configuration>
                            <configuration>
                                <home>${project.build.directory}/${cargo.containerid}-crowd/container</home>
                                <properties>
                                    <cargo.servlet.port>${crowd.testresource.cargo.servlet.port}</cargo.servlet.port>
                                </properties>
                            </configuration>
                        </configuration>
                    </execution>
                </executions>

            </plugin>

            <plugin>
                <!--
                Configure Surefire to run in the generate-resources phase, but not in the
                 normal test phase.
                -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>

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

                <executions>
                    <execution>
                        <id>setup-crowd</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <includes>
                                <include>**/SetupCrowdTest.java</include>
                            </includes>
                            <argLine>-Xmx128m</argLine>
                            <skip>false</skip>
                            <skipTests>false</skipTests>
                            <skipExec>false</skipExec>
                            <systemProperties>
                                <property>
                                    <name>acceptance.test.crowd.port</name>
                                    <value>${crowd.testresource.cargo.servlet.port}</value>
                                </property>
                                <property>
                                    <name>crowd.developer.license</name>
                                    <value>true</value>
                                </property>
                                <property>
                                    <name>skipTests</name>
                                    <value>false</value>
                                </property>
                                <property>
                                    <name>xvfb.enable</name>
                                    <value>${xvfb.enable}</value>
                                </property>
                                <property>
                                    <name>xvfb.display</name>
                                    <value>${xvfb.display}</value>
                                </property>
                            </systemProperties>
                        </configuration>
                    </execution>
                </executions>

            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>crowd-home</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <appendAssemblyId>false</appendAssemblyId>
                            <descriptors>
                                <descriptor>src/main/assembly/test-resources.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-clover2-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-verifier-plugin</artifactId>
                <configuration>
                    <basedir>${crowd.home}</basedir>
                    <verificationFile>src/main/verifier/verifications.xml</verificationFile>
                </configuration>
                <executions>
                    <execution>
                        <id>main</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>

    </build>
</project>
