<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.bamboo</groupId>
    <artifactId>atlassian-bamboo</artifactId>
    <version>4.4</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.atlassian.bamboo</groupId>
  <artifactId>atlassian-bamboo-ui-test</artifactId>

  <packaging>jar</packaging>

  <name>Atlassian Bamboo UI Test Module</name>

  <properties>
    <selenium.version>2.0b1</selenium.version>
    <installDir>${java.io.tmpdir}/cargo/installs</installDir>
    <serverPort>6990</serverPort>
    <brokerUri>tcp://localhost:61611</brokerUri>
    <serverJvmArgs>-server -Xms256m -Xmx512m -XX:MaxPermSize=256m -Djava.awt.headless=true -Dbamboo.enable.chains=true -DhideDashboard=false -DacceptanceTestSettings=${acceptanceTestSettings}</serverJvmArgs>
  </properties>



  <profiles>
    <!-- In 10.5 and later the tmp file paths contain plus chars which get evaluated incorrectly by java.net.URL and cause webwork and friends to die -->
    <profile>
      <id>uitest-macosx</id>
      <activation>
        <os>
          <family>mac</family>
        </os>
      </activation>
      <properties>
        <installDir>/tmp/cargo/installs</installDir>
      </properties>
    </profile>
    <profile>
      <id>uitest</id>
      <properties>
        <artifactToDeploy>atlassian-bamboo-web-app</artifactToDeploy>
        <containerId>tomcat6x</containerId>
        <downloadUrl>https://maven.atlassian.com/content/repositories/atlassian-public/org/apache/tomcat/apache-tomcat/6.0.26/apache-tomcat-6.0.26.zip</downloadUrl>
      </properties>

      <build>
        <plugins>

          <!-- Cargo plugin definition-->
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.0-atlassian-1</version>

            <!-- Default plugin definition for cargo maven plugin-->
            <configuration>

              <!-- Wait since we want the container startup to wait -->
              <wait>false</wait>

              <!-- Config the server to be started -->
              <container>
                <containerId>${containerId}</containerId>
                <output>${project.build.directory}/output.log</output>
                <log>${project.build.directory}/cargo-log.log</log>
                <systemProperties>
                  <bamboo.home>${project.build.directory}/bamboo-home</bamboo.home>
                  <bamboo.jms.broker.uri>${brokerUri}</bamboo.jms.broker.uri>
                </systemProperties>
                <!--<home>${containerHome}</home>-->
                <zipUrlInstaller>
                  <url>${downloadUrl}</url>
                  <installDir>${installDir}</installDir>
                </zipUrlInstaller>
              </container>

              <!-- Cargo config element -->
              <configuration>
                <home>${project.build.directory}/${containerId}/container</home>
                <properties>
                  <cargo.servlet.port>${serverPort}</cargo.servlet.port>
                  <cargo.rmi.port>10546</cargo.rmi.port>
                  <cargo.jvmargs>${serverJvmArgs}</cargo.jvmargs>
                  <cargo.logging>high</cargo.logging>
                </properties>
              </configuration>

              <deployer>
                <deployables>
                  <deployable>
                    <groupId>com.atlassian.bamboo</groupId>
                    <artifactId>${artifactToDeploy}</artifactId>
                    <type>war</type>
                    <pingURL>http://localhost:${serverPort}/bamboo</pingURL>
                    <pingTimeout>240000</pingTimeout>
                    <properties>
                      <context>bamboo</context>
                    </properties>
                  </deployable>
                </deployables>
              </deployer>

            </configuration>
            <!-- END maven config element -->

            <executions>
              <execution>
                <id>start-container</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start</goal>
                  <goal>deploy</goal>
                </goals>
              </execution>

              <execution>
                <id>stop-container</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <!-- Run the ${testClassName} as part of the test-->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
              <execution>
                <id>bamboo-webdriver-setup</id>
                <phase>integration-test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <skip>false</skip>
                  <includes>
                    <include>**/SetupBambooTest.java</include>
                  </includes>
                </configuration>
              </execution>
              <execution>
                <id>bamboo-webdriver-tests</id>
                <phase>integration-test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <excludes>
                    <exclude>**/SetupBambooTest.java</exclude>
                  </excludes>
                  <skip>false</skip>
                </configuration>
              </execution>
            </executions>
            <configuration>
              <argLine>-Xmx1024m</argLine>
              <skip>true</skip>
              <forkMode>never</forkMode>
              <systemPropertyVariables>
                <xvfb.enable>${xvfb.enable}</xvfb.enable>
                <bamboo.qunit.testoutput.location>${project.build.directory}/surefire-reports</bamboo.qunit.testoutput.location>
              </systemPropertyVariables>
              <!--<testClassesDirectory>${project.build.outputDirectory}</testClassesDirectory>-->
              <!--<testSourceDirectory>${project.build.sourceDirectory}</testSourceDirectory>-->
            </configuration>
          </plugin>

          <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <executions>
              <execution>
                <id>auto-clean</id>
                <phase>validate</phase>
                <goals>
                  <goal>clean</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.2</version>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>

    <!-- Module dependencies -->
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-web-app</artifactId>
      <type>war</type>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <groupId>commons-httpclient</groupId>
          <artifactId>commons-httpclient</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-pageobjects</artifactId>
      <exclusions>
        <exclusion>
          <groupId>commons-httpclient</groupId>
          <artifactId>commons-httpclient</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- For the tests to be able to assert resource keys-->
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-language</artifactId>
      <scope>compile</scope>
    </dependency>

    <!-- To hit the right URLs-->
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-api</artifactId>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <groupId>commons-httpclient</groupId>
          <artifactId>commons-httpclient</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.atlassian.aws</groupId>
          <artifactId>atlassian-aws</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpcore</artifactId>
    </dependency>

    <dependency>
      <groupId>com.atlassian.aui</groupId>
      <artifactId>aui-qunit-util</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
