<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.atlassian.confluence.plugins</groupId>
        <artifactId>confluence-notifications-tests-parent</artifactId>
        <version>20.0.83</version>
    </parent>

    <artifactId>confluence-email-litmus-tests</artifactId>
    <packaging>jar</packaging>

    <name>Confluence Email Litmus Tests</name>
    <description>A module hosting tests related to email visuals. Uses litmusapp.com</description>

    <properties>
        <confluence.home>${project.basedir}/src/test/resources/confluence/home/</confluence.home>
        <context.path>/confluence</context.path>
        <findbugs.skip>true</findbugs.skip>
        <!-- Hipchat Addon -->
        <!-- corresponds to the addon "Confluence (ci-pre-installed-do-not-delete)"-->
        <hipchat.addon.oauthid>bc84980e-f9a0-4c70-b436-0b47695e35df</hipchat.addon.oauthid>
        <hipchat.addon.oauthsecret.password>*</hipchat.addon.oauthsecret.password>
        <hipchat.addon.system.password>*</hipchat.addon.system.password>
        <hipchat.addon.system.token.password>*</hipchat.addon.system.token.password>
        <hipchat.addon.system.userId>136</hipchat.addon.system.userId>
        <!-- Hipchat System User -->
        <hipchat.addon.system.username>confluence.fe861aaa7e4e4401aa0802ddcfbf91d4@example.com</hipchat.addon.system.username>
        <hipchat.addon.token.password>*</hipchat.addon.token.password>
        <!--this id is used by the Installation test-->
        <hipchat.addon.uniqueid>ci</hipchat.addon.uniqueid>
        <hipchat.api.rooms.batch_size>1</hipchat.api.rooms.batch_size>
        <hipchat.api.rooms.page_size>2</hipchat.api.rooms.page_size>
        <!-- hipchat testing properties -->
        <hipchat.server.baseUrl>https://coco.hipch.at/</hipchat.server.baseUrl>
        <hipchat.server.default.id>${hipchat.server.groupId}_${hipchat.addon.system.userId}</hipchat.server.default.id>
        <hipchat.server.default.password>*</hipchat.server.default.password>
        <hipchat.server.default.userId>58</hipchat.server.default.userId>
        <!-- Some of these properties must be passed in - i.e. Passwords/Tokens-->
        <!-- Hipchat user -->
        <hipchat.server.default.username>conftest@example.com</hipchat.server.default.username>
        <hipchat.server.groupId>1</hipchat.server.groupId>
        <hipchat.server.name>btf.hipchat.com</hipchat.server.name>
        <litmus.account.name />
        <litmus.baseline.directory>${project.basedir}/src/test/resources/baseline</litmus.baseline.directory>
        <!--Test related properties-->
        <litmus.forkCount>1</litmus.forkCount>
        <litmus.login.password />
        <litmus.login.username />
        <litmus.report.output.directory>${project.build.directory}/litmus-report</litmus.report.output.directory>
        <litmus.smtp.server />
        <litmus.smtp.server.credentials />
        <litmus.smtp.server.tls />
        <litmus.tests.filter>1</litmus.tests.filter>
        <project.root.directory>${project.basedir}/../..</project.root.directory>
        <!-- To avoid duplicate indexing error -->
        <sonar.sources />
        <sonar.tests>src/main</sonar.tests>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.confluence.plugins</groupId>
            <artifactId>confluence-email-litmus-test-framework</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.core</groupId>
            <artifactId>atlassian-core-thumbnail</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-v2-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.selenium</groupId>
            <artifactId>atlassian-visual-comparison</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-not-shippable</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-testutils</artifactId>
            <version>${confluence.version}</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugin.notifications</groupId>
            <artifactId>notifications-module</artifactId>
        </dependency>
        <dependency>
            <groupId>io.atlassian.util.concurrent</groupId>
            <artifactId>atlassian-util-concurrent</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.jwebunit</groupId>
            <artifactId>jwebunit-core</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>jwebunit-confluence-plugin</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
            <artifactId>nekohtml</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
        </dependency>
        <!-- confluence-test-support provides most of the shared acceptance testing API and includes many dependencies. -->
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-test-support-restv2</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-test-utils</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.mail</groupId>
            <artifactId>atlassian-mail</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.mail</groupId>
            <artifactId>jakarta.mail-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence.plugins</groupId>
            <artifactId>confluence-content-notifications-plugin</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence.plugins</groupId>
            <artifactId>confluence-email-notifications-plugin</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence.plugins</groupId>
            <artifactId>confluence-notifications-batch-plugin</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence.plugins</groupId>
            <artifactId>confluence-notifications-spi-plugin</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.selenium</groupId>
            <artifactId>atlassian-webdriver-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-stateless-test-runner</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!--we don't want the litmus tests to run unless a test profile is switched on -->
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven-jar-plugin.version}</version>
                <executions>
                    <execution>
                        <id>test-jar</id>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>acceptance-tests</id>
            <activation>
                <property>
                    <name>run.acceptance.tests</name>
                </property>
            </activation>
            <properties>
                <acceptance.test.include-legacy>it/com/atlassian/confluence/notifications/content/**/*Test.java</acceptance.test.include-legacy>
                <acceptance.test.include-stateless>it/rest/**/*Test.java</acceptance.test.include-stateless>
                <acceptance.tests.skip>false</acceptance.tests.skip>
                <litmus.test.include>it/com/atlassian/confluence/notifications/litmus/**Test.java</litmus.test.include>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables combine.children="append">
                                <webdriver.browser>${webdriver.browser}</webdriver.browser>
                            </systemPropertyVariables>
                        </configuration>
                        <executions>
                            <execution>
                                <id>01_acceptance_test</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>integration-test</phase>
                                <configuration>
                                    <skipTests>${acceptance.tests.skip}</skipTests>
                                    <testClassesDirectory>${project.build.testOutputDirectory}</testClassesDirectory>
                                    <includes>
                                        <include>it/harness/EmailLitmusBatchedTests.java</include>
                                    </includes>
                                    <forkCount>${litmus.forkCount}</forkCount>
                                    <reuseForks>true</reuseForks>
                                    <systemPropertyVariables>
                                        <baseurl>http://localhost:${http.port}${context.path}</baseurl>
                                        <http.confluence.port>${http.port}</http.confluence.port>
                                        <context.confluence.path>${context.path}</context.confluence.path>
                                        <baseurl.confluence>http://localhost:${http.port}${context.path}</baseurl.confluence>
                                        <plugins.version>${project.version}</plugins.version>
                                        <enable.edge.cases.in.blogTitle>${enable.edge.cases.in.blogTitle}</enable.edge.cases.in.blogTitle>
                                        <!--
                                            We pass in the log4j config file because the surefire forking mechanism doesn't seem to
                                            pick up the one we have in the classpath (which contains the contents of
                                            confluence-test-support, which contains a log4j.properties that we would use). In any case,
                                            the forked test process doesn't redirect its console output back to the parent (a bug in surefire?),
                                            so the existing confluence test log4j properties file is useless for us.
                                        -->
                                        <log4j.configuration>file:${project.build.testOutputDirectory}/acceptance-test-1-log4j.properties</log4j.configuration>
                                    </systemPropertyVariables>
                                    <argLine>-Xmx256m</argLine>
                                    <!--
                                        uncomment the arg below to debug the forked test process. The port contains the forkNumber, which
                                        is wither 1 or 2 depending on which you want to connect to.
                                    -->
                                    <!--<argLine>-Xmx512m -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=50${surefire.forkNumber}5</argLine>-->
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>confluence-maven-plugin</artifactId>
                        <configuration>
                            <productVersion>${confluence.version}</productVersion>
                            <jvmArgs>${jvm.args}</jvmArgs>
                            <forceUpdateCheck>false</forceUpdateCheck>
                            <log4jProperties>${project.basedir}/src/test/resources/acceptance-test-1-log4j.properties</log4jProperties>
                            <output>${project.build.directory}/confluence-test-instance-1/output.log</output>
                            <systemPropertyVariables>
                                <atlassian.darkfeature.pulp.disable>true</atlassian.darkfeature.pulp.disable>
                            </systemPropertyVariables>
                            <products>
                                <product>
                                    <id>confluence</id>
                                    <instanceId>confluence-test-instance-1</instanceId>
                                    <version>${confluence.version}</version>
                                    <httpPort>${http.port}</httpPort>
                                    <systemPropertyVariables>
                                        <confluence.home>${project.build.directory}/confluence-test-instance-1/home</confluence.home>
                                    </systemPropertyVariables>
                                    <log4jProperties>${project.basedir}/src/test/resources/acceptance-test-1-log4j.properties</log4jProperties>
                                    <output>${project.build.directory}/confluence-test-instance-1/output.log</output>
                                    <pluginArtifacts>
                                        <pluginArtifact>
                                            <groupId>com.atlassian.plugin.notifications</groupId>
                                            <artifactId>notifications-module</artifactId>
                                            <version>${notifications.version}</version>
                                        </pluginArtifact>
                                        <pluginArtifact>
                                            <groupId>com.atlassian.confluence.plugins</groupId>
                                            <artifactId>confluence-content-notifications-plugin</artifactId>
                                            <version>${project.version}</version>
                                        </pluginArtifact>
                                        <pluginArtifact>
                                            <groupId>com.atlassian.confluence.plugins</groupId>
                                            <artifactId>confluence-email-notifications-plugin</artifactId>
                                            <version>${project.version}</version>
                                        </pluginArtifact>
                                        <pluginArtifact>
                                            <groupId>com.atlassian.confluence.plugins</groupId>
                                            <artifactId>confluence-notifications-batch-plugin</artifactId>
                                            <version>${project.version}</version>
                                        </pluginArtifact>
                                        <pluginArtifact>
                                            <groupId>com.atlassian.confluence.plugins</groupId>
                                            <artifactId>confluence-notifications-spi-plugin</artifactId>
                                            <version>${project.version}</version>
                                        </pluginArtifact>
                                    </pluginArtifacts>
                                </product>
                            </products>
                            <testGroups>
                                <testGroup>
                                    <id>content-tests</id>
                                    <productIds>
                                        <productId>confluence-test-instance-1</productId>
                                    </productIds>
                                </testGroup>
                            </testGroups>
                        </configuration>
                        <executions>
                            <execution>
                                <id>pre-integration-test</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <phase>pre-integration-test</phase>
                                <configuration>
                                    <wait>false</wait>
                                </configuration>
                            </execution>
                            <execution>
                                <id>post-integration-test</id>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                                <phase>post-integration-test</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>test-coverage</id>
            <properties>
                <jacoco.dump.port>6400</jacoco.dump.port>
            </properties>
        </profile>
    </profiles>
</project>
