<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2015 Google Inc. All Rights Reserved.

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>com.google.cloud.bigtable</groupId>
    <artifactId>bigtable-hbase-2.x-parent</artifactId>
    <version>1.26.3</version> <!-- {x-version-update:bigtable-client-parent:current} -->
  </parent>

  <artifactId>bigtable-hbase-2.x-integration-tests</artifactId>
  <packaging>jar</packaging>
  <name>${project.groupId}:${project.artifactId}</name>
  <description>
    This project contains test cases that ought to work for either
    bigtable-hbase or hbase proper.
  </description>

  <properties>
    <hbase.version>${hbase.version.2}</hbase.version>
    <google.bigtable.connection.impl>
      com.google.cloud.bigtable.hbase2_x.BigtableConnection
    </google.bigtable.connection.impl>
    <google.bigtable.async.connection.impl>
      org.apache.hadoop.hbase.client.BigtableAsyncConnection
    </google.bigtable.async.connection.impl>
    <google.bigtable.registry.impl>
      org.apache.hadoop.hbase.client.BigtableAsyncRegistry
    </google.bigtable.registry.impl>
    <test.timeout>2700</test.timeout>
  </properties>

  <profiles>
    <profile>
      <id>bigtableIntegrationTestH2</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
              <execution>
                <id>api-integration-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>none</phase>
              </execution>
              <execution>
                <id>api-gap-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>integration-test</phase>
                <configuration>
                  <forkCount>1</forkCount>
                  <includes>
                    <include>**/IntegrationTestsNoKnownGap.java</include>
                  </includes>
                  <reportNameSuffix>bigtable-server</reportNameSuffix>
                  <systemPropertyVariables>
                    <google.bigtable.connection.impl>
                      ${google.bigtable.connection.impl}
                    </google.bigtable.connection.impl>
                    <google.bigtable.async.connection.impl>
                      ${google.bigtable.async.connection.impl}
                    </google.bigtable.async.connection.impl>
                    <google.bigtable.registry.impl>
                      ${google.bigtable.registry.impl}
                    </google.bigtable.registry.impl>
                  </systemPropertyVariables>
                  <forkedProcessTimeoutInSeconds>
                    ${test.timeout}
                  </forkedProcessTimeoutInSeconds>
                  <!-- Make sure to fail the build when the suite fails to initialize -->
                  <failIfNoTests>true</failIfNoTests>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>bigtableGapTestH2</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <trimStackTrace>false</trimStackTrace>
            </configuration>
            <executions>
              <execution>
                <id>api-integration-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>none</phase>
              </execution>
              <execution>
                <id>api-gap-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>integration-test</phase>
                <configuration>
                  <!-- to enable netty logging, include:
                  -Djava.util.logging.config.file=src/test/resources/logging.properties
                  -->
                  <forkCount>1</forkCount>
                  <includes>
                    <include>**/IntegrationTestsGap.java</include>
                  </includes>
                  <reportNameSuffix>bigtable-server</reportNameSuffix>
                  <systemPropertyVariables>
                    <google.bigtable.connection.impl>
                      ${google.bigtable.connection.impl}
                    </google.bigtable.connection.impl>
                  </systemPropertyVariables>
                  <forkedProcessTimeoutInSeconds>
                    ${test.timeout}
                  </forkedProcessTimeoutInSeconds>
                  <trimStackTrace>false</trimStackTrace>
                  <!-- Make sure to fail the build when the suite fails to initialize -->
                  <failIfNoTests>true</failIfNoTests>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>hbaseLocalMiniClusterTestH2</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <trimStackTrace>false</trimStackTrace>
            </configuration>
            <executions>
              <execution>
                <id>api-integration-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>none</phase>
              </execution>
              <execution>
                <id>local-hbase-cluster-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>integration-test</phase>
                <configuration>
                  <includes>
                    <include>**/IntegrationTests.java</include>
                  </includes>
                  <reportNameSuffix>local-mini-cluster</reportNameSuffix>
                  <forkedProcessTimeoutInSeconds>
                    ${test.timeout}
                  </forkedProcessTimeoutInSeconds>
                  <trimStackTrace>false</trimStackTrace>
                  <!-- Make sure to fail the build when the suite fails to initialize -->
                  <failIfNoTests>true</failIfNoTests>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>simpleBigtableIntegrationTestH2</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <trimStackTrace>false</trimStackTrace>
            </configuration>
            <executions>
              <execution>
                <id>api-integration-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>none</phase>
              </execution>
              <execution>
                <id>api-gap-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>integration-test</phase>
                <configuration>
                  <forkCount>1</forkCount>
                  <environmentVariables>
                    <LD_LIBRARY_PATH>${ld.library.path}</LD_LIBRARY_PATH>
                  </environmentVariables>
                  <includes>
                    <include>**/SimpleIntegrationTests.java</include>
                  </includes>
                  <reportNameSuffix>bigtable-server</reportNameSuffix>
                  <systemPropertyVariables>
                    <google.bigtable.connection.impl>
                      ${google.bigtable.connection.impl}
                    </google.bigtable.connection.impl>
                    <compileSource>1.8</compileSource>
                  </systemPropertyVariables>
                  <!-- Make sure to fail the build when the suite fails to initialize -->
                  <failIfNoTests>true</failIfNoTests>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>emulatorTestsH2</id>
      <build>
        <plugins>
          <plugin>
            <groupId>${project.groupId}</groupId>
            <artifactId>bigtable-emulator-maven-plugin</artifactId>
            <version>1.26.3</version> <!-- {x-version-update:bigtable-client-parent:current} -->
            <executions>
              <execution>
                <goals>
                  <goal>start</goal>
                  <goal>stop</goal>
                </goals>
                <configuration>
                  <propertyName>bigtable.emulator.endpoint</propertyName>
                  <!-- Make sure to fail the build when the suite fails to initialize -->
                  <failIfNoTests>true</failIfNoTests>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
              <execution>
                <id>emulator-integration-test</id>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <includes>
                    <include>**/EmulatorTests.java</include>
                  </includes>
                  <reportNameSuffix>emulator</reportNameSuffix>
                  <systemPropertyVariables>
                    <google.bigtable.connection.impl>
                      ${google.bigtable.connection.impl}
                    </google.bigtable.connection.impl>
                    <google.bigtable.project.id>
                      fake-project
                    </google.bigtable.project.id>
                    <google.bigtable.instance.id>
                      fake-instance
                    </google.bigtable.instance.id>
                  </systemPropertyVariables>
                  <environmentVariables>
                    <BIGTABLE_EMULATOR_HOST>
                      ${bigtable.emulator.endpoint}
                    </BIGTABLE_EMULATOR_HOST>
                  </environmentVariables>
                  <trimStackTrace>false</trimStackTrace>
                  <forkedProcessTimeoutInSeconds>
                    ${test.timeout}
                  </forkedProcessTimeoutInSeconds>
                  <!-- Make sure to fail the build when the suite fails to initialize -->
                  <failIfNoTests>true</failIfNoTests>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java</artifactId>
        <version>${protobuf.version}</version>
      </dependency>
      <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java-util</artifactId>
        <version>${protobuf.version}</version>
      </dependency>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-bigtable-bom</artifactId>
        <version>${bigtable.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-bigtable-deps-bom</artifactId>
        <version>${bigtable.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <!-- Project Modules -->
    <dependency>
      <groupId>com.google.cloud.bigtable</groupId>
      <artifactId>bigtable-hbase</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
      <exclusions>
        <!-- included in hbase-shaded-testing-util -->
        <exclusion>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase-shaded-client</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>bigtable-hbase-2.x</artifactId>
      <version>1.26.3</version> <!-- {x-version-update:bigtable-client-parent:current} -->
      <scope>test</scope>
      <exclusions>
        <!-- included in hbase-shaded-testing-util -->
        <exclusion>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase-shaded-client</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>bigtable-hbase-integration-tests-common</artifactId>
      <version>${project.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>org.apache.hbase</artifactId>
          <groupId>*</groupId>
        </exclusion>
      </exclusions>
    </dependency>


    <!-- java-bigtable Modules -->
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-bigtable</artifactId>
      <scope>test</scope>
    </dependency>


    <!-- HBase testing tools -->
    <dependency>
      <groupId>org.apache.hbase</groupId>
      <artifactId>hbase-shaded-testing-util</artifactId>
      <version>${hbase.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- Misc -->
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
      <version>${jsr305.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${guava.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>${commons-lang.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- Testing deps -->
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
      <version>${hamcrest.version}</version>
      <scope>test</scope>
    </dependency>

    <!--  TODO: remove this dependency when upgraded through transitive dependency (http-client -> org.apache.httpcomponents:httpclient)
this is not used directly, but upgrading due to transitive vulnerabilities in older versions-->
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.15</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>${compileSource.1.8}</source>
          <target>${compileSource.1.8}</target>
          <showWarnings>true</showWarnings>
          <showDeprecation>false</showDeprecation>
          <compilerArgument>-Xlint:-options</compilerArgument>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <configuration>
          <useProjectReferences>false</useProjectReferences>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <trimStackTrace>false</trimStackTrace>
              <excludes>
                <exclude>**/*.java</exclude>
              </excludes>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <configuration>
          <usedDependencies>
            <usedDependency>${project.groupId}:bigtable-hbase-2.x
            </usedDependency>
            <!-- commons-codec is not used directly, but upgrading due to transitive vulnerabilities in older versions. -->
            <usedDependency>commons-codec:commons-codec</usedDependency>
          </usedDependencies>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
