<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) 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">
    <parent>
        <artifactId>wso2appserver</artifactId>
        <groupId>org.wso2.appserver</groupId>
        <version>6.0.0-m2</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>integration-tests</artifactId>
    <name>WSO2 Application Server - Integration Tests</name>
    <description>WSO2 Application Server Integration Tests</description>
    <url>http://wso2.com</url>

    <dependencies>
        <!-- WSO2 Application Server distribution -->
        <dependency>
            <groupId>org.wso2.appserver</groupId>
            <artifactId>wso2as</artifactId>
            <type>zip</type>
            <exclusions>
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Integration testing framework -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.databridge.core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>slf4j.wso2</groupId>
                    <artifactId>slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.databridge.receiver.thrift</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>slf4j.wso2</groupId>
                    <artifactId>slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xerces</artifactId>
        </dependency>
        <!-- WSO2 Application Server test artifacts -->
        <dependency>
            <groupId>org.wso2.appserver</groupId>
            <artifactId>configuration-loader</artifactId>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.wso2.appserver</groupId>
            <artifactId>configuration-loader-valve</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.agent</artifactId>
            <classifier>runtime</classifier>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeGroupIds>org.wso2.appserver</includeGroupIds>
                            <includeArtifactIds>wso2as</includeArtifactIds>
                            <outputDirectory>${project.build.directory}/</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-tomcat-test-components</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeGroupIds>org.wso2.appserver</includeGroupIds>
                            <includeArtifactIds>configuration-loader-valve</includeArtifactIds>
                            <outputDirectory>${project.build.directory}/${distribution.file.name}/lib</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-test-webapps</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeGroupIds>org.wso2.appserver</includeGroupIds>
                            <includeArtifactIds>configuration-loader</includeArtifactIds>
                            <outputDirectory>${project.build.directory}/${distribution.file.name}/webapps
                            </outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-jacoco-dependencies</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/jacoco/</outputDirectory>
                            <includeTypes>jar</includeTypes>
                            <includeArtifactIds>org.jacoco.agent</includeArtifactIds>
                            <stripVersion>true</stripVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>analyze-dependencies</id>
                        <goals>
                            <goal>analyze-only</goal>
                        </goals>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>analyze-dependency-management</id>
                        <goals>
                            <goal>analyze-dep-mgt</goal>
                        </goals>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <systemPropertyVariables>
                        <appserver.home>${project.build.directory}/${distribution.file.name}</appserver.home>
                        <appserver.version>${appserver.version}</appserver.version>
                        <build.directory>${project.build.directory}</build.directory>
                        <simplelogger.properties>simplelogger.properties</simplelogger.properties>
                        <listener.server.timeout>20</listener.server.timeout>
                        <port.check.min>8000</port.check.min>
                        <port.check.max>8100</port.check.max>
                        <jacoco-agent.dir>${project.build.directory}/jacoco/</jacoco-agent.dir>
                        <jacoco-agent.runtime>org.jacoco.agent-runtime.jar</jacoco-agent.runtime>
                        <jacoco-agent.data.file>jacoco-it.exec</jacoco-agent.data.file>
                    </systemPropertyVariables>

                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <configuration>
                            <target xmlns:jacoco="antlib:org.jacoco.ant">
                                <!--//this task is to provide class/src files locations for jacoco report generation-->
                                <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
                                    <classpath path="${project.build.directory}" />
                                </taskdef>
                                <jacoco:report>
                                    <executiondata>
                                        <file file="${project.build.directory}/jacoco/jacoco-it.exec" />
                                    </executiondata>
                                    <structure name="WSO2 Application Server 6.0.0 Module Integration Tests">
                                        <classfiles>
                                            <fileset dir="../modules/appserver-utils/target/classes" />
                                            <fileset dir="../modules/http-statistics-monitoring/target/classes" />
                                            <fileset dir="../modules/webapp-loader/target/classes" />
                                        </classfiles>
                                        <sourcefiles encoding="UTF-8">
                                            <fileset dir="../modules/appserver-utils/src/main/java/" />
                                            <fileset dir="../modules/http-statistics-monitoring/src/main/java/" />
                                            <fileset dir="../modules/webapp-loader/src/main/java/" />
                                        </sourcefiles>
                                    </structure>
                                    <html destdir="${project.build.directory}/site/jacoco" />
                                </jacoco:report>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.jacoco</groupId>
                        <artifactId>org.jacoco.ant</artifactId>
                        <version>${org.jacoco.ant.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>
