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

    Copyright 2015 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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.hawkular.agent</groupId>
    <artifactId>hawkular-agent-parent</artifactId>
    <version>0.6.1.Final</version>
  </parent>

  <artifactId>hawkular-agent-itest</artifactId>
  <name>Hawkular Agent Integration Tests</name>
  <description>A module containing integration tests of Command Gateway and Agent</description>

  <dependencies>

    <dependency>
      <groupId>com.squareup.okhttp</groupId>
      <artifactId>okhttp-ws</artifactId>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>

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

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <!-- because integration tests are run by maven-failsafe-plugin -->
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <!-- Integration tests -->
      <id>itest</id>
      <properties>
        <hawkular.bind.address>127.0.0.1</hawkular.bind.address>
        <hawkular.port.offset>0</hawkular.port.offset>
        <!-- $hawkular.management.port must be equal to $hawkular.port.offset + 9990 -->
        <hawkular.management.port>9990</hawkular.management.port>

        <hawkular.agent.enabled>true</hawkular.agent.enabled>

        <hawkular.log>INFO</hawkular.log>
        <hawkular.log.accounts>INFO</hawkular.log.accounts>
        <hawkular.log.agent>INFO</hawkular.log.agent>
        <hawkular.log.alerts>INFO</hawkular.log.alerts>
        <hawkular.log.bus>INFO</hawkular.log.bus>
        <hawkular.log.availcreator>INFO</hawkular.log.availcreator>
        <hawkular.log.pinger>INFO</hawkular.log.pinger>
        <hawkular.log.inventory>INFO</hawkular.log.inventory>
        <hawkular.log.metrics>INFO</hawkular.log.metrics>
        <hawkular.log.nest>INFO</hawkular.log.nest>
        <hawkular.log.datastax.driver>INFO</hawkular.log.datastax.driver>
        <hawkular.log.liquibase>WARN</hawkular.log.liquibase>
        <hawkular.log.cassandra>INFO</hawkular.log.cassandra>
        <hawkular.log.ejb3>WARN</hawkular.log.ejb3>
        <hawkular.log.rewrite>WARN</hawkular.log.rewrite>
        <http.log>ERROR</http.log>
        <http.log.wire>WARN</http.log.wire>
      </properties>
      <build>
        <plugins>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <includes>
                <include>**/*ITest*</include>
              </includes>
              <systemPropertyVariables>
                <hawkular.bind.address>${hawkular.bind.address}</hawkular.bind.address>
                <hawkular.port.offset>${hawkular.port.offset}</hawkular.port.offset>

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

          <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <configuration>
              <groupId>org.hawkular.agent</groupId>
              <artifactId>hawkular-agent-itest-dist</artifactId>
              <version>${project.version}</version>
              <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>-Djboss.modules.system.pkgs=org.jboss.byteman</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>-Dhawkular.agent.enabled=${hawkular.agent.enabled}</javaOpt>
                <javaOpt>-Dhawkular.log=${hawkular.log}</javaOpt>
                <javaOpt>-Dhawkular.log.accounts=${hawkular.log.accounts}</javaOpt>
                <javaOpt>-Dhawkular.log.agent=${hawkular.log.agent}</javaOpt>
                <javaOpt>-Dhawkular.log.alerts=${hawkular.log.alerts}</javaOpt>
                <javaOpt>-Dhawkular.log.bus=${hawkular.log.bus}</javaOpt>
                <javaOpt>-Dhawkular.log.availcreator=${hawkular.log.availcreator}</javaOpt>
                <javaOpt>-Dhawkular.log.pinger=${hawkular.log.pinger}</javaOpt>
                <javaOpt>-Dhawkular.log.inventory=${hawkular.log.inventory}</javaOpt>
                <javaOpt>-Dhawkular.log.metrics=${hawkular.log.metrics}</javaOpt>
                <javaOpt>-Dhawkular.log.nest=${hawkular.log.nest}</javaOpt>
                <javaOpt>-Dhawkular.log.datastax.driver=${hawkular.log.datastax.driver}</javaOpt>
                <javaOpt>-Dhawkular.log.liquibase=${hawkular.log.liquibase}</javaOpt>
                <javaOpt>-Dhawkular.log.cassandra=${hawkular.log.cassandra}</javaOpt>
                <javaOpt>-Dhawkular.log.ejb3=${hawkular.log.ejb3}</javaOpt>
                <javaOpt>-Dhawkular.log.rewrite=${hawkular.log.rewrite}</javaOpt>
                <javaOpt>-Dhawkular.log.rewrite=${hawkular.log.rewrite}</javaOpt>
                <!--<javaOpt>-Xdebug</javaOpt>-->
                <!--<javaOpt>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</javaOpt>-->
              </javaOpts>
            </configuration>
            <executions>
              <execution>
                <id>start-wildfly</id>
                <phase>pre-integration-test</phase>
                <configuration>
                  <server-config>standalone-itest.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>

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

</project>
