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

    Copyright 2014-2016 Red Hat, Inc. and/or its affiliates
    and other contributors as indicated by the @author tags.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<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>org.hawkular.metrics</groupId>
    <artifactId>hawkular-metrics-integration-tests</artifactId>
    <version>0.13.0.Final</version>
  </parent>

  <artifactId>hawkular-server-tests</artifactId>

  <name>Hawkular Metrics Rest Tests with Hawkular server</name>

  <properties>
    <hawkular.bind.address>127.0.0.1</hawkular.bind.address>
    <hawkular.port.offset>0</hawkular.port.offset>
    <hawkular.management.port>9990</hawkular.management.port>
    <hawkular.agent.enabled>false</hawkular.agent.enabled>
    <hawkular.log>ERROR</hawkular.log>
    <hawkular.backend>remote</hawkular.backend>
    <wildfly.application.username>jmsuser</wildfly.application.username>
    <wildfly.application.password>password</wildfly.application.password>
  </properties>

  <dependencies>

    <dependency>
      <groupId>org.wildfly</groupId>
      <artifactId>wildfly-client-all</artifactId>
      <version>${version.org.wildfly}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>hawkular-metrics-component</artifactId>
      <version>${project.version}</version>
      <type>war</type>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <scope>test</scope>
    </dependency>

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

    <dependency>
      <groupId>org.codehaus.groovy.modules.http-builder</groupId>
      <artifactId>http-builder</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.hawkular.accounts</groupId>
      <artifactId>hawkular-accounts-feature-pack</artifactId>
      <version>${version.org.hawkular.accounts}</version>
      <type>pom</type>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.hawkular.accounts</groupId>
      <artifactId>hawkular-accounts-feature-pack</artifactId>
      <version>${version.org.hawkular.accounts}</version>
      <type>zip</type>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/*ITest*</exclude>
          </excludes>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-deployments</id>
            <phase>test-compile</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <stripVersion>true</stripVersion>
              <artifactItems>
                <artifactItem>
                  <groupId>org.hawkular.metrics</groupId>
                  <artifactId>hawkular-metrics-component</artifactId>
                  <version>${project.version}</version>
                  <type>war</type>
                </artifactItem>
              </artifactItems>
              <outputDirectory>
                ${project.build.directory}/${project.build.finalName}/modules/system/layers/hawkular/org/hawkular/nest/main/deployments
              </outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.wildfly.build</groupId>
        <artifactId>wildfly-server-provisioning-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>server-provisioning</id>
            <goals>
              <goal>build</goal>
            </goals>
            <phase>compile</phase>
            <configuration>
              <config-file>server-provisioning.xml</config-file>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>xml-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>transform-standalone-xml</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>transform</goal>
            </goals>
            <configuration>
              <transformationSets>
                <!-- standalone.xml -->
                <transformationSet>
                  <dir>${project.build.directory}/${project.build.finalName}/standalone/configuration
                  </dir>
                  <stylesheet>src/main/resources/standalone.xsl</stylesheet>
                  <includes>
                    <include>standalone.xml</include>
                  </includes>
                  <outputDir>
                    ${project.build.directory}/${project.build.finalName}/standalone/configuration
                  </outputDir>
                </transformationSet>
              </transformationSets>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.wildfly.plugins</groupId>
        <artifactId>wildfly-maven-plugin</artifactId>
        <configuration>
          <add-user>
            <users>
              <user>
                <username>${wildfly.application.username}</username>
                <password>${wildfly.application.password}</password>
                <applicationUser>true</applicationUser>
                <groups>
                  <group>guest</group>
                </groups>
              </user>
            </users>
          </add-user>
          <jboss-home>${project.build.directory}/${project.build.finalName}</jboss-home>
          <skip>${skipTests}</skip>
          <startupTimeout>240</startupTimeout>
          <port>${hawkular.management.port}</port>
          <javaOpts>
            <javaOpt>-server</javaOpt>
            <javaOpt>-Xms64m</javaOpt>
            <javaOpt>-Xmx512m</javaOpt>
            <javaOpt>-Djava.net.preferIPv4Stack=true</javaOpt>
            <javaOpt>-Djava.awt.headless=true</javaOpt>
            <javaOpt>-Djboss.bind.address=${hawkular.bind.address}</javaOpt>
            <javaOpt>-Djboss.socket.binding.port-offset=${hawkular.port.offset}</javaOpt>
            <javaOpt>
              -Dkeycloak.import=${project.build.directory}/${project.build.finalName}/standalone/configuration/hawkular-realm-for-dev.json
            </javaOpt>
            <javaOpt>-Dhawkular.agent.enabled=${hawkular.agent.enabled}</javaOpt>
            <javaOpt>-Dhawkular.log=${hawkular.log}</javaOpt>
            <javaOpt>-Dhawkular.backend=${hawkular.backend}</javaOpt>
            <!--<javaOpt>-Xdebug</javaOpt>-->
            <javaOpt>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n</javaOpt>
          </javaOpts>
        </configuration>
        <executions>
          <execution>
            <id>start-wildfly</id>
            <phase>pre-integration-test</phase>
            <configuration>
              <server-config>standalone.xml</server-config>
            </configuration>
            <goals>
              <goal>start</goal>
            </goals>
          </execution>
          <execution>
            <id>stop-wildfly</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>shutdown</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
          <!-- if this is used maven reports always SUCCESS even if tests failed -->
          <!-- see https://stackoverflow.com/questions/16797601/maven-failsafe-plugin-errors-and-build-success -->
          <!--<dependenciesToScan>-->
          <!--<dependency>org.hawkular.inventory:hawkular-inventory-itest</dependency>-->
          <!--</dependenciesToScan>-->
          <testClassesDirectory>${project.build.testOutputDirectory}</testClassesDirectory>

          <includes>
            <include>**/*ITest*</include>
          </includes>

          <systemPropertyVariables>
            <hawkular.bind.address>${hawkular.bind.address}</hawkular.bind.address>
            <hawkular.port.offset>${hawkular.port.offset}</hawkular.port.offset>
            <wildfly.application.username>${wildfly.application.username}</wildfly.application.username>
            <wildfly.application.password>${wildfly.application.password}</wildfly.application.password>
            <hawkular.log>${hawkular.log}</hawkular.log>

            <!--output over-the-wire traffic-->
            <!--<org.apache.commons.logging.Log>-->
            <!--org.apache.commons.logging.impl.SimpleLog-->
            <!--</org.apache.commons.logging.Log>-->
            <!--<org.apache.commons.logging.simplelog.log.org.apache.http>-->
            <!--${http.log}-->
            <!--</org.apache.commons.logging.simplelog.log.org.apache.http>-->
            <!--<org.apache.commons.logging.simplelog.log.org.apache.http.wire>-->
            <!--${http.log.wire}-->
            <!--</org.apache.commons.logging.simplelog.log.org.apache.http.wire>-->
          </systemPropertyVariables>
          <!--<argLine>-Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y</argLine>-->
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
