<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>2.0-DR4</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

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

  <packaging>jar</packaging>

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

  <properties>
    <installDir>${java.io.tmpdir}/cargo/installs</installDir>
    <serverPort>9087</serverPort>
    <brokerUri>tcp://localhost:61610</brokerUri>
    <serverJvmArgs>-server -Xms256m -Xmx512m -XX:MaxPermSize=256m -Djava.awt.headless=true -DhideDashboard=true</serverJvmArgs>
  </properties>

  <profiles>
    <profile>
      <id>functest</id>
      <properties>
        <testClassName>BambooAcceptanceTestHarness</testClassName>
        <artifactToDeploy>atlassian-bamboo-web-app</artifactToDeploy>
        <containerId>tomcat5x</containerId>
        <downloadUrl>https://maven.atlassian.com/public/org/apache/tomcat/apache-tomcat/5.5.23/apache-tomcat-5.5.23.zip</downloadUrl>
      </properties>

      <build>
        <testResources>
          <testResource>
            <directory>src/it/resources</directory>
          </testResource>
        </testResources>
        <plugins>

          <!-- Run the ${testClassName} as part of the test-->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
              <execution>
                <phase>integration-test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <skip>false</skip>
                  <includes>
                    <include>**/*${testClassName}.java</include>
                  </includes>
                  <argLine>-Xmx1024m</argLine>
                </configuration>
              </execution>
            </executions>
            <configuration>
              <argLine>-Xmx1024m</argLine>
              <skip>true</skip>
            </configuration>
          </plugin>

          <!-- Make sure that the /it/resources is picked up in the resources phase -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>testResources</goal>
                </goals>
              </execution>
            </executions>
          </plugin>


          <!-- Cargo plugin definition-->
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>0.3.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>output.log</output>
                <log>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}/tomcat5x/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>

          <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>

    <profile>
      <id>remoteAgentFuncTest</id>
      <properties>
        <testClassName>RemoteAgentAcceptanceTestHarness</testClassName>
        <artifactToDeploy>atlassian-bamboo-web-app</artifactToDeploy>
        <containerId>tomcat5x</containerId>
        <downloadUrl>https://maven.atlassian.com/public/org/apache/tomcat/apache-tomcat/5.5.23/apache-tomcat-5.5.23.zip</downloadUrl>
        <serverPort>9987</serverPort>
        <brokerUri>tcp://localhost:61619</brokerUri>
      </properties>

      <build>
        <testResources>
          <testResource>
            <directory>src/it/resources</directory>
          </testResource>
        </testResources>
        <plugins>

          <!-- Run the ${testClassName} as part of the test-->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
              <execution>
                <phase>integration-test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <skip>false</skip>
                  <includes>
                    <include>**/*${testClassName}.java</include>
                  </includes>
                  <argLine>-Xmx1024m</argLine>
                </configuration>
              </execution>
            </executions>
            <configuration>
              <argLine>-Xmx1024m</argLine>
              <skip>true</skip>
              <systemProperties>
                <property>
                  <name>bamboo.jms.broker.uri</name>
                  <value>${brokerUri}</value>
                </property>
                <property>
                  <name>acceptance.test.webapp.port</name>
                  <value>${serverPort}</value>
                </property>
                <property>
                  <name>acceptance.test.webapp.context</name>
                  <value>/bamboo/</value>
                </property>
                <property>
                  <name>version</name>
                  <value>${project.version}</value>
                </property>
              </systemProperties>
            </configuration>
          </plugin>

          <!-- Make sure that the /it/resources is picked up in the resources phase -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>testResources</goal>
                </goals>
              </execution>
            </executions>
          </plugin>


          <!-- Cargo plugin definition-->
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>0.3.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>output.log</output>
                <log>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}/tomcat5x/container</home>
                <properties>
                  <cargo.servlet.port>${serverPort}</cargo.servlet.port>
                  <cargo.rmi.port>10547</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>

          <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>

    <profile>
      <id>ldap</id>
      <properties>
        <testClassName>BambooLdapTestHarness</testClassName>
        <artifactToDeploy>atlassian-bamboo-ldap-web-app</artifactToDeploy>
        <serverPort>9187</serverPort>
        <brokerUri>tcp://localhost:61611</brokerUri>

      </properties>
      <dependencies>

        <!-- Module dependencies -->
        <dependency>
          <groupId>com.atlassian.bamboo</groupId>
          <artifactId>atlassian-bamboo-ldap-web-app</artifactId>
          <type>war</type>
        </dependency>
      </dependencies>
    </profile>

    <!-- Servers -->
    <profile>
      <id>tomcat5</id>
      <properties>
        <testClassName>MinimalAcceptanceTestHarness</testClassName>
        <containerId>tomcat5x</containerId>
        <downloadUrl>https://maven.atlassian.com/public/org/apache/tomcat/apache-tomcat/5.0.30/jakarta-tomcat-5.0.30.zip</downloadUrl>
        <serverPort>9287</serverPort>
        <brokerUri>tcp://localhost:61612</brokerUri>

      </properties>
    </profile>

    <profile>
      <id>tomcat55</id>
      <properties>
        <testClassName>MinimalAcceptanceTestHarness</testClassName>
        <containerId>tomcat5x</containerId>
        <downloadUrl>https://maven.atlassian.com/public/org/apache/tomcat/apache-tomcat/5.5.23/apache-tomcat-5.5.23.zip</downloadUrl>
        <serverPort>9387</serverPort>
        <brokerUri>tcp://localhost:61613</brokerUri>

      </properties>
    </profile>

    <profile>
      <id>tomcat6</id>
      <properties>
        <testClassName>MinimalAcceptanceTestHarness</testClassName>
        <containerId>tomcat5x</containerId>
        <downloadUrl>https://maven.atlassian.com/public/org/apache/tomcat/apache-tomcat/6.0.14/apache-tomcat-6.0.14.zip</downloadUrl>
        <serverPort>9487</serverPort>
        <brokerUri>tcp://localhost:61614</brokerUri>

      </properties>
    </profile>

    <profile>
      <id>orion2</id>
      <properties>
        <testClassName>MinimalAcceptanceTestHarness</testClassName>
        <containerId>orion2x</containerId>
        <downloadUrl>http://www.orionserver.com/distributions/orion2.0.7.zip</downloadUrl>
        <serverPort>9587</serverPort>
        <brokerUri>tcp://localhost:61615</brokerUri>

      </properties>
    </profile>

    <profile>
      <id>resin3</id>
      <properties>
        <testClassName>MinimalAcceptanceTestHarness</testClassName>
        <containerId>resin3x</containerId>
        <downloadUrl>http://www.caucho.com/download/resin-3.0.24.zip</downloadUrl>
        <serverPort>9687</serverPort>
        <brokerUri>tcp://localhost:61616</brokerUri>

      </properties>
    </profile>

    <profile>
      <id>resin31</id>
      <properties>
        <testClassName>MinimalAcceptanceTestHarness</testClassName>
        <containerId>resin3x</containerId>
        <downloadUrl>http://www.caucho.com/download/resin-3.1.2.zip</downloadUrl>
        <serverPort>9787</serverPort>
        <brokerUri>tcp://localhost:61617</brokerUri>

      </properties>
    </profile>

    <profile>
      <id>jboss4</id>
      <properties>
        <testClassName>MinimalAcceptanceTestHarness</testClassName>
        <containerId>jboss4x</containerId>
        <downloadUrl>http://downloads.sourceforge.net/jboss/jboss-4.0.5.GA.zip?big_mirror=1</downloadUrl>
        <serverPort>9887</serverPort>
        <brokerUri>tcp://localhost:61618</brokerUri>

      </properties>
    </profile>

  </profiles>

  <dependencies>

    <!-- Module dependencies -->
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-web-app</artifactId>
      <type>war</type>
    </dependency>

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

    <!-- To hit the right URLs-->
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-api</artifactId>
    </dependency>

    <!-- Atlassian dependencies -->

    <!-- Other dependencies -->
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
    </dependency>

    <dependency>
      <groupId>tomcat</groupId>
      <artifactId>jasper-compiler</artifactId>
    </dependency>

    <dependency>
      <groupId>tomcat</groupId>
      <artifactId>jasper-runtime</artifactId>
    </dependency>

    <dependency>
      <groupId>net.sourceforge.jwebunit</groupId>
      <artifactId>jwebunit-htmlunit-plugin</artifactId>
    </dependency>

    <dependency>
      <groupId>jaxen</groupId>
      <artifactId>jaxen</artifactId>
      <version>1.1.1</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
    </dependency>

    <dependency>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty</artifactId>
    </dependency>

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

    <dependency>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-core-api-container</artifactId>
    </dependency>

    <dependency>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-core-api-generic</artifactId>
    </dependency>

    <dependency>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-core-container-tomcat</artifactId>
      <scope>runtime</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jsp-api</artifactId>
      <scope>runtime</scope>
    </dependency>

  </dependencies>

  <build>
    <testSourceDirectory>src/it/java</testSourceDirectory>
  </build>


  <pluginRepositories>
    <pluginRepository>
      <id>codehaus snapshot repository</id>
      <url>http://snapshots.repository.codehaus.org/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
    </pluginRepository>
  </pluginRepositories>


</project>