<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2017, 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>
        <groupId>org.wso2.carbon.analytics</groupId>
        <artifactId>org.wso2.carbon.analytics.parent</artifactId>
        <version>2.0.310</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>carbon-analytics-osgi-tests</artifactId>
    <name>WSO2 Carbon Analytics - OSGi Tests</name>
    <description>OSGi Tests for WSO2 Carbon Analytics</description>
    <url>http://wso2.com</url>

    <dependencies>
        <dependency>
            <groupId>org.wso2.siddhi</groupId>
            <artifactId>siddhi-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.analytics</groupId>
            <artifactId>org.wso2.carbon.stream.processor.statistics</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.osgi</groupId>
            <artifactId>org.eclipse.osgi.services</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-container-native</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-testng</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-link-mvn</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.url</groupId>
            <artifactId>pax-url-aether</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ow2.spec.ee</groupId>
            <artifactId>ow2-jta-1.1-spec</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.ant</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.container</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
        </dependency>
        <!--Pax exam Container Carbon-->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.analytics</groupId>
            <artifactId>org.wso2.carbon.analytics.test.distribution</artifactId>
            <type>zip</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>osgi-test-util</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.analytics</groupId>
            <artifactId>org.wso2.carbon.status.dashboard.core</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.101tec</groupId>
            <artifactId>zkclient</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Testing purposes -->
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_2.11</artifactId>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>local-mysql</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.ops4j.pax.exam</groupId>
                        <artifactId>maven-paxexam-plugin</artifactId>
                        <version>1.2.4</version>
                        <executions>
                            <execution>
                                <id>generate-config</id>
                                <goals>
                                    <goal>generate-depends-file</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-distribution</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wso2.carbon.analytics</groupId>
                                            <artifactId>org.wso2.carbon.analytics.test.distribution</artifactId>
                                            <type>zip</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-jacoco-dependencies</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <includeTypes>jar</includeTypes>
                                    <includeArtifactIds>org.jacoco.ant</includeArtifactIds>
                                    <stripVersion>true</stripVersion>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.18.1</version>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-docker-for-mysql</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-docker-for-mysql</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>remove</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <verbose>true</verbose>
                            <images>
                                <image>
                                    <alias>sp-mysql</alias>
                                    <name>mysql:5.7</name>
                                    <run>
                                        <namingStrategy>alias</namingStrategy>
                                        <env>
                                            <MYSQL_DATABASE>WSO2_ANALYTICS_DB</MYSQL_DATABASE>
                                            <MYSQL_ROOT_PASSWORD>root</MYSQL_ROOT_PASSWORD>
                                        </env>
                                        <ports>
                                            <port>32910:3306</port>
                                        </ports>
                                        <wait>
                                            <tcp>
                                                <ports>
                                                    <port>3306</port>
                                                </ports>
                                            </tcp>
                                            <log>mysqld: ready for connections</log>
                                            <time>60000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>integration-test-for-mysql</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>verify-for-mysql</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <argLine>${jcoverage.command}</argLine>
                            <systemPropertyVariables>
                                <org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}
                                </org.ops4j.pax.url.mvn.localRepository>
                                <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
                                <org.wso2.carbon.test.default.distribution>
                                    org.wso2.carbon.analytics:org.wso2.carbon.analytics.test.distribution
                                </org.wso2.carbon.test.default.distribution>
                                <org.ops4j.pax.logging.DefaultServiceLog.level>DEBUG
                                </org.ops4j.pax.logging.DefaultServiceLog.level>
                                <carbon.analytic.version>${carbon.analytics.version}</carbon.analytic.version>
                            </systemPropertyVariables>
                            <environmentVariables>
                                <DATABASE_TYPE>MySQL</DATABASE_TYPE>
                                <DATABASE_USER>root</DATABASE_USER>
                                <DATABASE_PASSWORD>root</DATABASE_PASSWORD>
                                <PORT>32910</PORT>
                                <DOCKER_HOST_IP>${docker.container.sp-mysql.ip}</DOCKER_HOST_IP>
                            </environmentVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testngdocker.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jacoco-initialize</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/jacoco.exec</destFile>
                                    <propertyName>jcoverage.command</propertyName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>post-integration-test</phase>
                                <configuration>
                                    <target xmlns:jacoco="antlib:org.jacoco.ant">
                                        <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
                                            <classpath path="${project.build.directory}" />
                                        </taskdef>
                                        <!-- OSGi Test coverage only enabled for org.wso2.carbon.stream.core module-->
                                        <jacoco:report>
                                            <executiondata>
                                                <file file="${project.build.directory}/jacoco.exec" />
                                            </executiondata>
                                            <structure name="Stream processor core OSGi Tests">
                                                <classfiles>
                                                    <fileset dir="../org.wso2.carbon.stream.processor.core/target/classes" />
                                                </classfiles>
                                                <sourcefiles encoding="UTF-8">
                                                    <fileset dir="../org.wso2.carbon.stream.processor.core/src" />
                                                </sourcefiles>
                                            </structure>
                                            <html destdir="${project.build.directory}/coverage-reports" />
                                        </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>
        </profile>
        <profile>
            <id>local-postgres</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.ops4j.pax.exam</groupId>
                        <artifactId>maven-paxexam-plugin</artifactId>
                        <version>1.2.4</version>
                        <executions>
                            <execution>
                                <id>generate-config</id>
                                <goals>
                                    <goal>generate-depends-file</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-distribution</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wso2.carbon.analytics</groupId>
                                            <artifactId>org.wso2.carbon.analytics.test.distribution</artifactId>
                                            <type>zip</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-jacoco-dependencies</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <includeTypes>jar</includeTypes>
                                    <includeArtifactIds>org.jacoco.ant</includeArtifactIds>
                                    <stripVersion>true</stripVersion>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.18.1</version>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-docker-for-postgres</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-docker-for-postgres</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>remove</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <verbose>true</verbose>
                            <images>
                                <image>
                                    <alias>sp-postgres</alias>
                                    <name>postgres:9.6</name>
                                    <run>
                                        <namingStrategy>alias</namingStrategy>
                                        <env>
                                            <POSTGRES_PASSWORD>root</POSTGRES_PASSWORD>
                                            <POSTGRES_USER>root</POSTGRES_USER>
                                            <POSTGRES_DB>WSO2_ANALYTICS_DB</POSTGRES_DB>
                                        </env>
                                        <ports>
                                            <port>32908:5432</port>
                                        </ports>
                                        <wait>
                                            <tcp>
                                                <ports>
                                                    <port>5432</port>
                                                </ports>
                                            </tcp>
                                            <log>postgres: ready for connections</log>
                                            <time>60000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>integration-test-for-postgres</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>verify-for-postgres</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <argLine>${jcoverage.command}</argLine>
                            <systemPropertyVariables>
                                <org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}
                                </org.ops4j.pax.url.mvn.localRepository>
                                <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
                                <org.wso2.carbon.test.default.distribution>
                                    org.wso2.carbon.analytics:org.wso2.carbon.analytics.test.distribution
                                </org.wso2.carbon.test.default.distribution>
                                <org.ops4j.pax.logging.DefaultServiceLog.level>DEBUG
                                </org.ops4j.pax.logging.DefaultServiceLog.level>
                                <carbon.analytic.version>${carbon.analytics.version}</carbon.analytic.version>
                            </systemPropertyVariables>
                            <environmentVariables>
                                <DATABASE_TYPE>POSTGRES</DATABASE_TYPE>
                                <DATABASE_USER>root</DATABASE_USER>
                                <DATABASE_PASSWORD>root</DATABASE_PASSWORD>
                                <PORT>32908</PORT>
                                <DOCKER_HOST_IP>${docker.container.sp-postgres.ip}</DOCKER_HOST_IP>
                            </environmentVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testngdocker.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jacoco-initialize</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/jacoco.exec</destFile>
                                    <propertyName>jcoverage.command</propertyName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>post-integration-test</phase>
                                <configuration>
                                    <target xmlns:jacoco="antlib:org.jacoco.ant">
                                        <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
                                            <classpath path="${project.build.directory}" />
                                        </taskdef>
                                        <!-- OSGi Test coverage only enabled for org.wso2.carbon.stream.core module-->
                                        <jacoco:report>
                                            <executiondata>
                                                <file file="${project.build.directory}/jacoco.exec" />
                                            </executiondata>
                                            <structure name="Stream processor core OSGi Tests">
                                                <classfiles>
                                                    <fileset dir="../org.wso2.carbon.stream.processor.core/target/classes" />
                                                </classfiles>
                                                <sourcefiles encoding="UTF-8">
                                                    <fileset dir="../org.wso2.carbon.stream.processor.core/src" />
                                                </sourcefiles>
                                            </structure>
                                            <html destdir="${project.build.directory}/coverage-reports" />
                                        </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>
        </profile>
        <profile>
            <id>local-mssql</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.18.1</version>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.ops4j.pax.exam</groupId>
                        <artifactId>maven-paxexam-plugin</artifactId>
                        <version>1.2.4</version>
                        <executions>
                            <execution>
                                <id>generate-config</id>
                                <goals>
                                    <goal>generate-depends-file</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-distribution</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wso2.carbon.analytics</groupId>
                                            <artifactId>org.wso2.carbon.analytics.test.distribution</artifactId>
                                            <type>zip</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-jacoco-dependencies</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <includeTypes>jar</includeTypes>
                                    <includeArtifactIds>org.jacoco.ant</includeArtifactIds>
                                    <stripVersion>true</stripVersion>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-docker-for-mssql</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-docker-for-mssql</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>remove</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <images>
                                <image>
                                    <name>microsoft/mssql-server-linux:2017-GA</name>
                                    <alias>sp-mssql</alias>
                                    <run>
                                        <namingStrategy>alias</namingStrategy>
                                        <volumes>
                                            <bind>
                                                <volume>mssql_server_data:/var/opt/mssql/data</volume>
                                            </bind>
                                        </volumes>
                                        <env>
                                            <ACCEPT_EULA>Y</ACCEPT_EULA>
                                            <SA_PASSWORD>wso2das123#</SA_PASSWORD>
                                        </env>
                                        <ports>
                                            <port>32906:1433</port>
                                        </ports>
                                        <wait>
                                            <log>Service Broker manager has started.</log>
                                            <time>180000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>integration-test-for-mssql</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>verify-for-mssql</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <argLine>${jcoverage.command}</argLine>
                            <systemPropertyVariables>
                                <org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}
                                </org.ops4j.pax.url.mvn.localRepository>
                                <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
                                <org.wso2.carbon.test.default.distribution>
                                    org.wso2.carbon.analytics:org.wso2.carbon.analytics.test.distribution
                                </org.wso2.carbon.test.default.distribution>
                                <org.ops4j.pax.logging.DefaultServiceLog.level>DEBUG
                                </org.ops4j.pax.logging.DefaultServiceLog.level>
                                <carbon.analytic.version>${carbon.analytics.version}</carbon.analytic.version>
                            </systemPropertyVariables>
                            <environmentVariables>
                                <DATABASE_TYPE>MSSQL</DATABASE_TYPE>
                                <DATABASE_USER>sa</DATABASE_USER>
                                <DATABASE_PASSWORD>wso2das123#</DATABASE_PASSWORD>
                                <PORT>32906</PORT>
                                <DOCKER_HOST_IP>${docker.container.sp-mssql.ip}</DOCKER_HOST_IP>
                                <JAVA_OPTS>${jcoverage.command}</JAVA_OPTS>
                            </environmentVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testngdocker.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jacoco-initialize</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/jacoco.exec</destFile>
                                    <propertyName>jcoverage.command</propertyName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>post-integration-test</phase>
                                <configuration>
                                    <target xmlns:jacoco="antlib:org.jacoco.ant">
                                        <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
                                            <classpath path="${project.build.directory}" />
                                        </taskdef>
                                        <!-- OSGi Test coverage only enabled for org.wso2.carbon.stream.core module-->
                                        <jacoco:report>
                                            <executiondata>
                                                <file file="${project.build.directory}/jacoco.exec" />
                                            </executiondata>
                                            <structure name="Stream processor core OSGi Tests">
                                                <classfiles>
                                                    <fileset dir="../org.wso2.carbon.stream.processor.core/target/classes" />
                                                </classfiles>
                                                <sourcefiles encoding="UTF-8">
                                                    <fileset dir="../org.wso2.carbon.stream.processor.core/src" />
                                                </sourcefiles>
                                            </structure>
                                            <html destdir="${project.build.directory}/coverage-reports" />
                                        </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>
        </profile>
        <profile>
            <id>local-oracle</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.18.1</version>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.ops4j.pax.exam</groupId>
                        <artifactId>maven-paxexam-plugin</artifactId>
                        <version>1.2.4</version>
                        <executions>
                            <execution>
                                <id>generate-config</id>
                                <goals>
                                    <goal>generate-depends-file</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-distribution</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wso2.carbon.analytics</groupId>
                                            <artifactId>org.wso2.carbon.analytics.test.distribution</artifactId>
                                            <type>zip</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-jacoco-dependencies</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <includeTypes>jar</includeTypes>
                                    <includeArtifactIds>org.jacoco.ant</includeArtifactIds>
                                    <stripVersion>true</stripVersion>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-docker-for-oracle</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop-docker-for-oracle</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>stop</goal>
                                    <goal>remove</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <images>
                                <image>
                                    <alias>sp-oracle</alias>
                                    <name>dockerhub.private.wso2.com/sajithd-oracle-database:11.2.0.2-xe</name>
                                    <run>
                                        <namingStrategy>alias</namingStrategy>
                                        <env>
                                            <ORACLE_PWD>root</ORACLE_PWD>
                                        </env>
                                        <ports>
                                            <port>32904:1521</port>
                                        </ports>
                                        <wait>
                                            <log>DATABASE IS READY TO USE!</log>
                                            <time>400000</time>
                                        </wait>
                                        <shmSize>2718281829</shmSize>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>integration-test-for-oracle</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>verify-for-oracle</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <argLine>${jcoverage.command}</argLine>
                            <systemPropertyVariables>
                                <org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}
                                </org.ops4j.pax.url.mvn.localRepository>
                                <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
                                <org.wso2.carbon.test.default.distribution>
                                    org.wso2.carbon.analytics:org.wso2.carbon.analytics.test.distribution
                                </org.wso2.carbon.test.default.distribution>
                                <org.ops4j.pax.logging.DefaultServiceLog.level>DEBUG
                                </org.ops4j.pax.logging.DefaultServiceLog.level>
                                <carbon.analytic.version>${carbon.analytics.version}</carbon.analytic.version>
                            </systemPropertyVariables>
                            <environmentVariables>
                                <DATABASE_TYPE>ORACLE</DATABASE_TYPE>
                                <DATABASE_USER>system</DATABASE_USER>
                                <DATABASE_PASSWORD>root</DATABASE_PASSWORD>
                                <PORT>32904</PORT>
                                <DOCKER_HOST_IP>${docker.container.sp-oracle.ip}</DOCKER_HOST_IP>
                                <JAVA_OPTS>${jcoverage.command}</JAVA_OPTS>
                            </environmentVariables>
                            <argLine>-Duser.timezone=GMT</argLine>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testngdocker.xml</suiteXmlFile>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jacoco-initialize</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/jacoco.exec</destFile>
                                    <propertyName>jcoverage.command</propertyName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>post-integration-test</phase>
                                <configuration>
                                    <target xmlns:jacoco="antlib:org.jacoco.ant">
                                        <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
                                            <classpath path="${project.build.directory}" />
                                        </taskdef>
                                        <!-- OSGi Test coverage only enabled for org.wso2.carbon.stream.core module-->
                                        <jacoco:report>
                                            <executiondata>
                                                <file file="${project.build.directory}/jacoco.exec" />
                                            </executiondata>
                                            <structure name="Stream processor core OSGi Tests">
                                                <classfiles>
                                                    <fileset dir="../org.wso2.carbon.stream.processor.core/target/classes" />
                                                </classfiles>
                                                <sourcefiles encoding="UTF-8">
                                                    <fileset dir="../org.wso2.carbon.stream.processor.core/src" />
                                                </sourcefiles>
                                            </structure>
                                            <html destdir="${project.build.directory}/coverage-reports" />
                                        </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>
        </profile>

        <profile>
            <id>with-tests</id>
            <activation>
                <property>
                    <name>!maven.test.skip</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-distribution</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wso2.carbon.analytics</groupId>
                                            <artifactId>org.wso2.carbon.analytics.test.distribution</artifactId>
                                            <type>zip</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-jacoco-dependencies</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <includeTypes>jar</includeTypes>
                                    <includeArtifactIds>org.jacoco.ant</includeArtifactIds>
                                    <stripVersion>true</stripVersion>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.18.1</version>
                        <configuration>
                            <systemPropertyVariables>
                                <org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}
                                </org.ops4j.pax.url.mvn.localRepository>
                                <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
                                <org.wso2.carbon.test.default.distribution>
                                    org.wso2.carbon.analytics:org.wso2.carbon.analytics.test.distribution
                                </org.wso2.carbon.test.default.distribution>
                                <org.ops4j.pax.logging.DefaultServiceLog.level>DEBUG
                                </org.ops4j.pax.logging.DefaultServiceLog.level>
                                <carbon.analytic.version>${carbon.analytics.version}</carbon.analytic.version>
                            </systemPropertyVariables>
                            <suiteXmlFiles>
                                <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                            </suiteXmlFiles>
                            <environmentVariables>
                                <JAVA_OPTS>${jcoverage.command}</JAVA_OPTS>
                                <DATABASE_TYPE>H2</DATABASE_TYPE>
                            </environmentVariables>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jacoco-initialize</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/jacoco.exec</destFile>
                                    <propertyName>jcoverage.command</propertyName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>post-integration-test</phase>
                                <configuration>
                                    <target xmlns:jacoco="antlib:org.jacoco.ant">
                                        <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
                                            <classpath path="${project.build.directory}" />
                                        </taskdef>
                                        <!-- OSGi Test coverage only enabled for org.wso2.carbon.stream.core module-->
                                        <jacoco:report>
                                            <executiondata>
                                                <file file="${project.build.directory}/jacoco.exec" />
                                            </executiondata>
                                            <structure name="Stream processor core OSGi Tests">
                                                <classfiles>
                                                    <fileset dir="../org.wso2.carbon.stream.processor.core/target/classes" />
                                                    <fileset dir="../org.wso2.carbon.stream.processor.statistics/target/classes" />
                                                    <fileset dir="../org.wso2.carbon.siddhi.store.api.rest/target/classes" />
                                                    <fileset dir="../org.wso2.carbon.sp.jobmanager.core/target/classes" />
                                                    <fileset dir="../org.wso2.carbon.event.simulator.core/target/classes" />
                                                </classfiles>
                                                <sourcefiles encoding="UTF-8">
                                                    <fileset dir="../org.wso2.carbon.stream.processor.core/src" />
                                                    <fileset dir="../org.wso2.carbon.stream.processor.statistics/src" />
                                                    <fileset dir="../org.wso2.carbon.siddhi.store.api.rest/src" />
                                                    <fileset dir="../org.wso2.carbon.sp.jobmanager.core/src" />
                                                    <fileset dir="../org.wso2.carbon.event.simulator.core/src" />
                                                </sourcefiles>
                                            </structure>
                                            <html destdir="${project.build.directory}/coverage-reports" />
                                        </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>
                    <plugin>
                        <groupId>org.ops4j.pax.exam</groupId>
                        <artifactId>maven-paxexam-plugin</artifactId>
                        <version>1.2.4</version>
                        <executions>
                            <execution>
                                <id>generate-config</id>
                                <goals>
                                    <goal>generate-depends-file</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <properties>
        <surefireArgLine />
    </properties>

</project>