<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2016, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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.jboss.integration</groupId>
        <artifactId>narayana-tomcat-all</artifactId>
        <version>1.0.0.Final</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>narayana-tomcat</artifactId>
    <name>Narayana: Tomcat JTA integration</name>
    <properties>
        <jvm.args.debug></jvm.args.debug>
        <jvm.args.byteman>
            -Dorg.jboss.byteman.verbose -Djboss.modules.system.pkgs=org.jboss.byteman -Dorg.jboss.byteman.transform.all
            -javaagent:${project.build.directory}/lib/byteman.jar=script:${project.build.directory}/test-classes/scripts.btm,listener:true
        </jvm.args.byteman>
        <server.jvm.args>${jvm.args.byteman} ${jvm.args.debug}</server.jvm.args>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-dbcp</artifactId>
            <version>${version.org.apache.tomcat}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.transaction</groupId>
            <artifactId>jboss-transaction-api_1.2_spec</artifactId>
            <version>${version.org.jboss.spec.javax.transaction}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.narayana</groupId>
            <artifactId>common</artifactId>
            <version>${version.org.jboss.narayana}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.narayana.arjunacore</groupId>
            <artifactId>arjuna</artifactId>
            <version>${version.org.jboss.narayana}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.narayana.jta</groupId>
            <artifactId>jta</artifactId>
            <version>${version.org.jboss.narayana}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.narayana.jta</groupId>
            <artifactId>jdbc</artifactId>
            <version>${version.org.jboss.narayana}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss</groupId>
            <artifactId>jboss-transaction-spi</artifactId>
            <version>${version.org.jboss.jboss-transaction-spi}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.spec.javax.transaction</groupId>
                    <artifactId>jboss-transaction-api_1.2_spec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>${version.org.jboss.logging.jboss-logging}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${version.javax.servlet}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <version>${version.org.jboss.arquillian.core}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-container-spi</artifactId>
            <version>${version.org.jboss.arquillian.core}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
            <version>${version.org.jboss.shrinkwrap.resolver}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
            <version>${version.org.jboss.resteasy}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-servlet-initializer</artifactId>
            <version>${version.org.jboss.resteasy}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <version>${version.org.jboss.resteasy}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.byteman</groupId>
            <artifactId>byteman</artifactId>
            <version>${version.org.jboss.byteman}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.byteman</groupId>
            <artifactId>byteman-submit</artifactId>
            <version>${version.org.jboss.byteman}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.byteman</groupId>
            <artifactId>byteman-bmunit</artifactId>
            <version>${version.org.jboss.byteman}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.integration</groupId>
            <version>${project.version}</version>
            <artifactId>test-utils</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>${version.com.h2database}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-catalina</artifactId>
            <version>${version.org.apache.tomcat}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <inherited>false</inherited>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <arjuna-properties-file>jbossts-properties.xml</arjuna-properties-file>
                        </manifestEntries>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>create-test-jar</id>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>**/Test*.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>arq-tomcat</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.arquillian.container</groupId>
                    <artifactId>arquillian-tomcat-managed-8</artifactId>
                    <version>${version.org.jboss.arquillian.container.tomcat}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                                <configuration>
                                    <skip>false</skip>
                                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                                    <forkCount>0</forkCount>
                                    <systemPropertyVariables combine.children="append">
                                        <project.version>${project.version}</project.version>
                                        <project.build.directory>${project.build.directory}</project.build.directory>
                                        <version.org.jboss.narayana>${version.org.jboss.narayana}</version.org.jboss.narayana>
                                        <version.org.jboss.resteasy>${version.org.jboss.resteasy}</version.org.jboss.resteasy>
                                        <version.org.jboss.spec.javax.transaction>${version.org.jboss.spec.javax.transaction}</version.org.jboss.spec.javax.transaction>
                                        <server.jvm.args>${server.jvm.args}</server.jvm.args>
                                        <tomcat.user>arquillian</tomcat.user>
                                        <tomcat.pass>arquillian</tomcat.pass>

                                        <!--
                                        h2:
                                          By default, the integration test runs with "h2" database, platform independent and in-memory.
                                        pgsql:
                                          If selected, the TS runs against a remote, always present PostgreSQL database server available in the Narayana CI.
                                        container:
                                          It requires a running Docker daemon the user executing this TS has the rights to control
                                          A database is started as a Docker container and it is discarded at the end of testing.
                                        dballocator:
                                          It requires an instance of DBAllocator running in your infrastructure. It enables the TS to
                                          lease various databases, including but not limited to Sybase, DB2, MS SQL, Maria, Postgress, Oracle...
                                        -->
                                        <test.db.type>h2</test.db.type>

                                        <!-- pgsql properties -->
                                        <version.postgresql>${version.postgresql}</version.postgresql>
                                        <pgsql.user>dtf11</pgsql.user>
                                        <pgsql.password>dtf11</pgsql.password>
                                        <pgsql.servername>narayanaci1.eng.hst.ams2.redhat.com</pgsql.servername>
                                        <pgsql.portnumber>5432</pgsql.portnumber>
                                        <pgsql.databasename>jbossts</pgsql.databasename>

                                        <!-- h2 properties -->
                                        <version.com.h2database>${version.com.h2database}</version.com.h2database>

                                        <!-- container properties -->
                                        <container.database.image>postgres:10</container.database.image>
                                        <container.database.driver.artifact>org.postgresql:postgresql:42.2.2</container.database.driver.artifact>
                                        <container.database.driver.class>org.postgresql.Driver</container.database.driver.class>
                                        <container.database.datasource.class.xa>org.postgresql.xa.PGXADataSource</container.database.datasource.class.xa>
                                        <container.docker.daemon.api.url>tcp://127.0.0.1:2375</container.docker.daemon.api.url>
                                        <container.name>narayana_db</container.name>
                                        <container.database.username>narayana_user</container.database.username>
                                        <container.database.password>narayana_pass</container.database.password>
                                        <container.database.name>narayana_db</container.database.name>
                                        <container.database.bind.host.ip>127.0.0.1</container.database.bind.host.ip>
                                        <container.database.bind.host.port>5432</container.database.bind.host.port>
                                        <!-- The undermentioned timeout accounts both for pulling image and starting container up to opened socket. -->
                                        <container.timeout.waiting.for.tcp>240000</container.timeout.waiting.for.tcp>

                                        <db.timeout.waiting.for.heartbeat.statement>120000</db.timeout.waiting.for.heartbeat.statement>
                                        <db.timeout.heartbeat.statement>SELECT 1;</db.timeout.heartbeat.statement>

                                        <!-- dballocator properties -->
                                        <dballocator.host.port>http://your.db.allocator.example.com:8080</dballocator.host.port>
                                        <dballocator.expression>postgresql94</dballocator.expression>
                                        <dballocator.requestee>narayana-tomcat-ts</dballocator.requestee>
                                        <dballocator.expiry.minutes>10</dballocator.expiry.minutes>
                                        <dballocator.timeout.minutes>20</dballocator.timeout.minutes>
                                        <dballocator.driver.url>http://your.fileserver.example.com/postgresql-42.1.1.jar</dballocator.driver.url>
                                        <dballocator.driver.url.timeout.seconds>120</dballocator.driver.url.timeout.seconds>
                                    </systemPropertyVariables>
                                </configuration>
                            </execution>
                            <execution>
                                <id>verify</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-dependencies</id>
                                <phase>test-compile</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <stripVersion>true</stripVersion>
                                    <includeGroupIds>org.jboss.byteman</includeGroupIds>
                                    <outputDirectory>${project.build.directory}/lib</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>codeCoverage</id>
            <properties>
                <server.jvm.args>
                    ${jvm.args.byteman} ${jvm.args.debug} ${jvm.args.jacoco}
                </server.jvm.args>
            </properties>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-install-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>default-install</id>
                                <phase>install</phase>
                            </execution>
                        </executions>
                        <inherited>false</inherited>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
