<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">
    <parent>
        <groupId>com.atlassian.pom</groupId>
        <artifactId>atlassian-contrib-pom</artifactId>
        <version>12</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.atlassian.confluence.plugin</groupId>
    <artifactId>func-test</artifactId>
    <packaging>atlassian-plugin</packaging>
    <version>2.2-beta1</version>
    <name>Confluence Plugin Functional Test Library</name>
    <url>http://maven.apache.org</url>

    <properties>
        <http.port>1990</http.port>
        <rmi.port>9899</rmi.port>
        <cargo.wait>false</cargo.wait>

        <maven.test.it.skip>${maven.test.skip}</maven.test.it.skip>
        <maven.test.unit.skip>${maven.test.skip}</maven.test.unit.skip>

        <tomcat.installer.url>
            https://m2proxy.atlassian.com/repository/public/org/apache/tomcat/apache-tomcat/5.5.23/apache-tomcat-5.5.23-jdk14.zip
        </tomcat.installer.url>

        <base.webapp.directory>${project.build.directory}</base.webapp.directory>

        <confluence.version>3.0.1</confluence.version>
        <confluence.data.version>2.10</confluence.data.version>
        <confluence.http.port>${http.port}</confluence.http.port>
        <confluence.rmi.port>${rmi.port}</confluence.rmi.port>
        <confluence.wait>${cargo.wait}</confluence.wait>

        <jdkLevel>1.5</jdkLevel>

        <jvmargs.debug.confluence />
        <jvmargs>-XX:MaxPermSize=256m -Xms128m -Xmx564m</jvmargs>
    </properties>

    <organization>
        <name>Atlassian Pty Ltd</name>
        <url>http://www.atlassian.com/</url>
    </organization>

    <profiles>
        <profile>
            <id>plugin-debug</id>
            <build>
                <defaultGoal>verify</defaultGoal>
            </build>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <maven.test.skip>true</maven.test.skip>
                <base.webapp.directory>${project.build.directory}/debug</base.webapp.directory>
                <cargo.wait>true</cargo.wait>

                <jvmargs.debug.confluence>-Xdebug -Xnoagent
                    -Xrunjdwp:server=y,transport=dt_socket,address=5005,suspend=n
                </jvmargs.debug.confluence>
            </properties>
        </profile>
    </profiles>

    <scm>
        <connection>scm:svn:https://svn.atlassian.com/svn/public/contrib/confluence/confluence-plugin-func-test/tags/func-test-2.2-beta1</connection>
        <developerConnection>scm:svn:https://svn.atlassian.com/svn/public/contrib/confluence/confluence-plugin-func-test/tags/func-test-2.2-beta1</developerConnection>
        <url>http://svn.atlassian.com/fisheye/browse/public/contrib/confluence/confluence-plugin-func-test/tags/func-test-2.2-beta1</url>
    </scm>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.jwebunit</groupId>
            <artifactId>jwebunit-htmlunit-plugin</artifactId>
            <version>1.4.1</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>dom4j</groupId>
                    <artifactId>dom4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>jdom</groupId>
                    <artifactId>jdom</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xalan</groupId>
                    <artifactId>xalan</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-collections</groupId>
                    <artifactId>commons-collections</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-lang</groupId>
                    <artifactId>commons-lang</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-httpclient</groupId>
                    <artifactId>commons-httpclient</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-codec</groupId>
                    <artifactId>commons-codec</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-io</groupId>
                    <artifactId>commons-io</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xercesImpl</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-codec</groupId>
                    <artifactId>commons-codec</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>nekohtml</groupId>
                    <artifactId>nekohtml</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>atlassian-plugin.xml</include>
                    <include>func-test.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>func-test.properties</exclude>
                    <exclude>atlassian-plugin.xml</exclude>
                    <exclude>webtester.properties.example</exclude>
                </excludes>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>axistools-maven-plugin</artifactId>
                <configuration>
                    <urls>
                        <url>https://extranet.atlassian.com/rpc/soap-axis/confluenceservice-v1?wsdl</url>
                    </urls>
                    <outputDirectory>src/main/java</outputDirectory>
                    <packageSpace>com.atlassian.confluence.plugin.functest.remote.soap.stub</packageSpace>
                    <testCases>false</testCases>
                    <serverSide>false</serverSide>
                    <subPackageByFileName>false</subPackageByFileName>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>${maven.test.unit.skip}</skip>
                    <excludes>
                        <exclude>it/**/*</exclude>
                        <exclude>**/*Abstract*</exclude>
                        <exclude>**/*Mock*</exclude>
                        <exclude>**/*$*</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>acceptance_tests</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skip>${maven.test.it.skip}</skip>
                            <excludes>
                                <exclude>none</exclude>
                                <exclude>**/*Abstract*</exclude>
                                <exclude>**/*Mock*</exclude>
                                <exclude>**/*$*</exclude>
                            </excludes>
                            <includes>
                                <include>it/**/*java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-integration-test-config</id>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <tasks>
                                <mkdir dir="${project.build.directory}/test-classes" />

                                <taskdef name="propertyfile" classname="org.apache.tools.ant.taskdefs.optional.PropertyFile" classpathref="maven.plugin.classpath" />
                                <propertyfile file="${project.build.directory}/test-classes/webtester.properties" comment="Confluence plugin functional test configuration file">
                                    <entry key="confluence.auth.admin.username" value="admin" />
                                    <entry key="confluence.auth.admin.password" value="admin" />
                                    <entry key="confluence.webapp.protocol" value="http" />
                                    <entry key="confluence.webapp.host" value="localhost" />
                                    <entry key="confluence.webapp.port" value="${http.port}" />
                                    <entry key="confluence.webapp.context.path" value="/confluence" />
                                    <entry key="confluence.webapp.soap.path" value="/rpc/soap-axis/confluenceservice-v1?wsdl" />
                                    <entry key="confluence.plugin.jar" value="${project.build.directory}/${project.build.finalName}.jar" />
                                    <!--
                                    Indicate whether the plugin should be installed as as bundled plugin (something that will be done by Atlassian Test Harness).
                                    If this property is false, the plugin test lib will install the plugin, once per integration-test phase.
                                    -->
                                    <entry key="confluence.plugin.bundled" value="false" />
                                    <entry key="confluence.data.export" value="${basedir}/src/test/resources/confluence-demo-site.zip" />
                                    <entry key="maven.settings.localRepository" value="${settings.localRepository}" />
                                </propertyfile>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant-nodeps</artifactId>
                        <version>1.6.5</version>
                    </dependency>
                    <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant-optional</artifactId>
                        <version>1.5.2</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>com.atlassian.maven.plugins.testharness</groupId>
                <artifactId>atlassian-test-harness</artifactId>
                <version>0.11-beta3</version>

                <executions>
                    <execution>
                        <id>start-confluence</id>
                        <goals>
                            <goal>start-confluence</goal>
                        </goals>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <version>3.0.1</version>
                            <testResourcesVersion>${confluence.data.version}</testResourcesVersion>

                            <container>
                                <containerId>tomcat5x</containerId>
                                <installerUrl>${tomcat.installer.url}</installerUrl>
                                <containerHome>${base.webapp.directory}/confluence/tomcat5x</containerHome>
                                <outputLog>${base.webapp.directory}/confluence/output.log</outputLog>
                                <httpPort>${confluence.http.port}</httpPort>
                                <controlPort>${confluence.rmi.port}</controlPort>
                                <context>confluence</context>
                                <jvmArgs>${jvmargs} ${jvmargs.debug.confluence}</jvmArgs>

                                <startService>true</startService>
                                <wait>${confluence.wait}</wait>
                            </container>

                            <service>
                                <installThisArtifact>false</installThisArtifact>
                                <configDirectory>
                                    ${base.webapp.directory}/confluence/confluence-config
                                </configDirectory>
                                <webappDirectory>
                                    ${base.webapp.directory}/confluence/confluence-webapp
                                </webappDirectory>
                            </service>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>atlassian-pdk</artifactId>
                <version>2.1.6</version>
                <extensions>true</extensions>
                <configuration>
                    <extractDependencies>false</extractDependencies>
                </configuration>
            </plugin>

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