<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>5.6-m3</version>
    </parent>

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

    <name>Confluence Load Tests</name>
    <description>This module includes tests that put a large amount of data into Confluence and see how it responds.</description>

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

    <profiles>
        <profile>
            <id>load</id>
            <build>
                <plugins>
                    <plugin>
                        <!--
                        Use the dependency plugin to unpack the Confluence WAR.
                        -->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.0-alpha-4</version>
                        <executions>
                            <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>
                        </configuration>
                        <executions>
                            <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>load-test-confluence</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <includes>
                                        <include>com/atlassian/confluence/it/load/*LoadTest.java</include>
                                    </includes>
                                    <excludes>
                                        <exclude>**/Abstract*.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-confluence-container</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                                <configuration>
                                    <wait>${cargo.confluence.wait}</wait>
                                    <container>
                                        <containerId>tomcat7x</containerId>
                                        <zipUrlInstaller>
                                            <url>${tomcat7.url}</url>
                                            <extractDir>${cargo.container.zipurlinstaller.installdir}</extractDir>
                                        </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}/tomcat7x-confluence/container</home>
                                        <properties>
                                            <cargo.servlet.port>${http.port}</cargo.servlet.port>
                                            <cargo.servlet.uriencoding>UTF-8</cargo.servlet.uriencoding>
                                            <cargo.rmi.port>${controller.port}</cargo.rmi.port>
                                            <cargo.tomcat.ajp.port>${ajp.port}</cargo.tomcat.ajp.port>
                                            <cargo.jvmargs>${jvm.args}</cargo.jvmargs>
                                        </properties>
                                    </configuration>
                                    <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}/${webappContext}</pingURL>
                                            <pingTimeout>240000</pingTimeout>
                                        </deployable>
                                    </deployables>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <!-- activates the maven clean plugin configuration from the parent -->
                        <artifactId>maven-clean-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <cargo.confluence.wait>false</cargo.confluence.wait>
                <unpack.stuff>true</unpack.stuff>
            </properties>
        </profile>
    </profiles>

</project>

