<?xml version="1.0" encoding="UTF-8"?>

<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-embedded-crowd</artifactId>
        <version>2.1.1</version>
    </parent>

    <artifactId>embedded-crowd-test-runner</artifactId>
    <name>Atlassian Embedded Crowd - Integration Test Runner</name>
    <packaging>atlassian-plugin</packaging>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>embedded-crowd-admin-plugin-test</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <!-- This breaks the test runner, but is needed in embedded-crowd-admin-plugin-test to run the test in IDEA. -->
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>embedded-crowd-admin-plugin</artifactId>
            <type>atlassian-plugin</type>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.selenium</groupId>
            <artifactId>atlassian-pageobjects-elements</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.refapp</groupId>
            <artifactId>atlassian-refapp-pageobjects</artifactId>
            <version>${refapp.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.5</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.selenium</groupId>
            <artifactId>atlassian-webdriver-confluence</artifactId>
            <version>${atlassian.selenium.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>atlassian-jira-pageobjects</artifactId>
            <version>${jira.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-simple</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-library</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>embedded-crowd-refapp-plugin</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.atlassian.crowd</groupId>
                                    <artifactId>embedded-crowd-admin-plugin-test</artifactId>
                                    <version>${project.version}</version>
                                    <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- Starts an external LDAP server for use by LDAPTest, DirectoriesTest etc -->
                <groupId>com.btmatthews.maven.plugins</groupId>
                <artifactId>ldap-maven-plugin</artifactId>
                <!-- We use 1.1.0 here because 1.2.0 runs ApacheDS 2.0.0-M12 -->
                <version>1.1.0</version>
                <executions>
                    <execution>
                        <id>start-apacheds</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <monitorKey>ldap</monitorKey>
                            <monitorPort>11389</monitorPort>
                            <daemon>true</daemon>
                            <rootDn>ou=system</rootDn>
                            <ldapPort>10389</ldapPort>
                            <ldifFile>${basedir}/src/test/ldap-maven-plugin/ldapSchema.ldif</ldifFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop-apacheds</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                        <configuration>
                            <monitorKey>ldap</monitorKey>
                            <monitorPort>11389</monitorPort>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-amps-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <!-- Don't try to install 'embedded-crowd-test-runner' as a plugin -->
                    <installPlugin>false</installPlugin>

                    <systemPropertyVariables>
                        <xvfb.enable>${xvfb.enable}</xvfb.enable>
                        <upm.pac.disable>true</upm.pac.disable>
                        <atlassian.upm.server.data.disable>true</atlassian.upm.server.data.disable>
                    </systemPropertyVariables>

                    <products>
                        <product>
                            <id>refapp</id>
                            <instanceId>refapp</instanceId>
                            <version>${refapp.version}</version>
                            <containerId>tomcat7x</containerId>
                            <enableFastdev>false</enableFastdev>
                            <enableDevToolbox>false</enableDevToolbox>
                            <enablePde>false</enablePde>
                            <bundledArtifacts>
                                <bundledArtifact>
                                    <groupId>com.atlassian.crowd</groupId>
                                    <artifactId>embedded-crowd-refapp-plugin</artifactId>
                                    <version>${project.version}</version>
                                </bundledArtifact>
                            </bundledArtifacts>
                            <pluginArtifacts>
                                <pluginArtifact>
                                    <groupId>com.atlassian.crowd</groupId>
                                    <artifactId>embedded-crowd-admin-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                            </pluginArtifacts>
                        </product>
                        <product>
                            <id>confluence</id>
                            <instanceId>confluence</instanceId>
                            <version>${confluence.version}</version>
                            <dataVersion>${confluence.data.version}</dataVersion>
                            <containerId>tomcat8x</containerId>
                            <jvmArgs>-Xmx1024m</jvmArgs>
                            <pluginArtifacts>
                                <pluginArtifact>
                                    <groupId>com.atlassian.crowd</groupId>
                                    <artifactId>embedded-crowd-admin-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                            </pluginArtifacts>
                        </product>
                        <product>
                            <id>jira</id>
                            <instanceId>jira</instanceId>
                            <version>${jira.version}</version>
                            <dataVersion>${jira.data.version}</dataVersion>
                            <containerId>tomcat7x</containerId>
                            <jvmArgs>-Xmx1024m</jvmArgs>
                            <pluginArtifacts>
                                <pluginArtifact>
                                    <groupId>com.atlassian.crowd</groupId>
                                    <artifactId>embedded-crowd-admin-plugin</artifactId>
                                    <version>${project.version}</version>
                                </pluginArtifact>
                                <pluginArtifact>
                                    <!-- This is for JiraTestedProduct.backdoor().darkFeatures() in AbstractEmbeddedCrowdTest.
                                         I'm not sure why it isn't present by default when using JiraTestedProduct. -->
                                    <groupId>com.atlassian.jira.tests</groupId>
                                    <artifactId>jira-testkit-plugin</artifactId>
                                    <version>${jira.testkit.version}</version>
                                </pluginArtifact>
                            </pluginArtifacts>
                            <systemProperties>
                                <!-- DEVSPEED-185 -->
                                <property>
                                    <name>jira.websudo.is.disabled</name>
                                    <value>true</value>
                                </property>
                            </systemProperties>
                        </product>
                        <product>
                            <!-- Crowd-as-a-Crowd-Server -->
                            <id>crowd</id>
                            <instanceId>crowd</instanceId>
                            <version>${crowd.product.version}</version>
                            <dataPath>${project.basedir}/src/test/amps/crowd-plugin-test-resources-2.2.4-generic-application.zip</dataPath>
                            <containerId>tomcat7x</containerId>
                        </product>
                        <product>
                            <!-- JAACS instance -->
                            <id>jira</id>
                            <instanceId>jira-jaacs</instanceId>
                            <version>${jira.version}</version>
                            <dataPath>${project.basedir}/src/test/amps/jira-plugin-test-resources-7.0-20150427.154805-plus-crowd-application.zip</dataPath>
                            <containerId>tomcat7x</containerId>
                            <jvmArgs>-Xmx1024m</jvmArgs>
                            <httpPort>2991</httpPort>
                        </product>
                    </products>

                    <testGroups>
                        <!-- If you add more groups here, also add them to the plan template EMBCWD-DEF 'Master main build'. -->
                        <testGroup>
                            <id>refapp</id>
                            <productIds>
                                <productId>refapp</productId>
                            </productIds>
                            <includes>
                                <include>it/**</include>
                            </includes>
                            <systemProperties>
                                <tested.app>com.atlassian.webdriver.refapp.RefappTestedProduct</tested.app>
                            </systemProperties>
                        </testGroup>
                        <testGroup>
                            <id>confluence</id>
                            <productIds>
                                <productId>confluence</productId>
                                <productId>crowd</productId>
                                <productId>jira-jaacs</productId>
                            </productIds>
                            <includes>
                                <include>it/**</include>
                            </includes>
                            <systemProperties>
                                <tested.app>com.atlassian.webdriver.confluence.ConfluenceTestedProduct</tested.app>
                            </systemProperties>
                        </testGroup>
                        <testGroup>
                            <id>jira</id>
                            <productIds>
                                <productId>jira</productId>
                                <productId>crowd</productId>
                                <productId>jira-jaacs</productId>
                            </productIds>
                            <includes>
                                <include>it/**</include>
                            </includes>
                            <systemProperties>
                                <tested.app>com.atlassian.jira.pageobjects.JiraTestedProduct</tested.app>
                            </systemProperties>
                        </testGroup>
                    </testGroups>

                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>it/**/*.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <!-- Whether the functional tests should be run detached from the current screen -->
        <xvfb.enable>true</xvfb.enable>

        <!-- Warning: at the time of writing, it doesn't work to run multiple test groups e.g. '-DtestGroups=confluence,jira':
             AMPS isn't isolating things enough, so some products break in the second group.
             For now:
             - Release build uses the single testGroup here;
               confluence by default, because the refapp tests don't exercise as much (no real external servers)
             - Master build EMBCWD-DEF runs a job per testGroup
             - To test locally, run with '-DtestGroups=jira' as needed. -->
        <testGroups>confluence</testGroups>

        <jira.data.version>${jira.version}</jira.data.version>
        <jira.testkit.version>7.0.76</jira.testkit.version>
        <confluence.version>5.9.1-OD-2015.43.0-0343</confluence.version>
        <confluence.data.version>${confluence.version}</confluence.data.version>
        <crowd.product.version>${crowd.version}</crowd.product.version>
        <stash.version>1.0.0-m19</stash.version>
    </properties>

</project>
