<?xml version="1.0"?>
<!--
/**
 * Copyright (c) Codice Foundation
 *
 * 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 3 of the License, or any later version.
 *
 * This program 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. A copy of the GNU Lesser General Public License is distributed along with this program and can be found at
 * <http://www.gnu.org/licenses/lgpl.html>.
 *
 **/
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.codice.alliance.test.itests</groupId>
        <artifactId>itests</artifactId>
        <version>1.17.5</version>
    </parent>
    <artifactId>test-itests-alliance</artifactId>
    <name>Alliance :: Integration :: Test</name>

    <properties>
        <surefire.argline.append>-Dddf.version=${ddf.version}</surefire.argline.append>
        <solr.script.dir>
            ${project.build.directory}/solr/bin/
        </solr.script.dir>
        <solr.port>9784</solr.port>
        <zookeeper.port>10784</zookeeper.port>
    </properties>

    <dependencies>
        <!--start pax-exam dependencies-->
        <dependency>
            <groupId>org.apache.karaf.bundle</groupId>
            <artifactId>org.apache.karaf.bundle.core</artifactId>
            <version>${karaf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-container-karaf</artifactId>
            <version>${pax.exam.version}</version>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam-junit4</artifactId>
            <version>${pax.exam.version}</version>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.exam</groupId>
            <artifactId>pax-exam</artifactId>
            <version>${pax.exam.version}</version>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.url</groupId>
            <artifactId>pax-url-aether</artifactId>
            <version>${pax.url.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>${javax.inject.version}</version>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.tinybundles</groupId>
            <artifactId>tinybundles</artifactId>
            <version>${pax.tinybundles.version}</version>
        </dependency>
        <!--end pax-exam dependencies-->

        <!--start ddf dependencies-->
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>${restassured.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ddf.thirdparty</groupId>
            <artifactId>restito</artifactId>
            <version>${ddf.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ddf.catalog.core</groupId>
            <artifactId>catalog-core-api</artifactId>
            <version>${ddf.version}</version>
            <scope>test</scope>
        </dependency>
        <!--end ddf dependencies-->

        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>${awaitility.version}</version>
        </dependency>
        <dependency>
            <groupId>org.codice.alliance.test.itests</groupId>
            <artifactId>test-itests-common</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.codice.alliance.distribution</groupId>
            <artifactId>sample-mpegts-streamgenerator</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.codice.alliance.distribution</groupId>
            <artifactId>alliance</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.codice.alliance.security</groupId>
            <artifactId>banner-marking</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.codice.alliance.test.itests</groupId>
            <artifactId>test-itests-dependencies-app</artifactId>
            <version>${project.version}</version>
            <classifier>features</classifier>
            <type>xml</type>
        </dependency>
        <dependency>
            <groupId>org.codice.alliance.distribution</groupId>
            <artifactId>sdk-app</artifactId>
            <version>${project.version}</version>
            <classifier>features</classifier>
            <type>xml</type>
        </dependency>
        <dependency>
            <groupId>ddf</groupId>
            <artifactId>solr-distro</artifactId>
            <version>${ddf.version}</version>
            <classifier>assembly</classifier>
            <type>zip</type>
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-transport</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-handler</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-common</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-transport-native-epoll</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>ddf.platform.security</groupId>
            <artifactId>security-rest-clientapi</artifactId>
            <version>${ddf.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>Windows</id>
            <activation>
                <os>
                    <family>Windows</family>
                </os>
            </activation>
            <properties>
                <solr.script.file>solr.cmd</solr.script.file>
                <solr.force />
            </properties>
        </profile>
        <profile>
            <id>Unix</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <solr.script.file>solr</solr.script.file>
                <solr.force>-force</solr.force>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>make-solr-executable</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>chmod</executable>
                                    <arguments>
                                        <argument>+x</argument>
                                        <argument>
                                            ${solr.script.dir}${solr.script.file}
                                        </argument>
                                    </arguments>
                                    <async>true</async>
                                    <asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <!--Unpack Solr distribution-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-solr</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>ddf</groupId>
                                    <artifactId>solr-distro</artifactId>
                                    <version>${ddf.version}</version>
                                    <type>zip</type>
                                    <classifier>assembly</classifier>
                                    <!--FYI: Maven dependency plugin ignores the instruction "destFileName"-->
                                    <!--if the goal is "unpack"-->
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <configuration>
                    <!--Do not run this plugin exection if the we are skipping tests-->
                    <skip>${skipTests}</skip>
                    <longModulepath>false</longModulepath>
                </configuration>
                <executions>
                    <execution>
                        <id>ensure-solr-is-stopped</id>
                        <phase>pre-clean</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${solr.script.dir}${solr.script.file}</executable>
                            <arguments>
                                <argument>stop</argument>
                                <argument>-p</argument>
                                <argument>${solr.port}</argument>
                            </arguments>
                            <async>true</async>
                            <asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
                            <successCodes>
                                <successCode>0</successCode>
                                <successCode>1</successCode>
                            </successCodes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>start-solr</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>
                                ${solr.script.dir}${solr.script.file}
                            </executable>
                            <arguments>
                                <argument>start</argument>
                                <argument>-c</argument>
                                <argument>-p</argument>
                                <argument>${solr.port}</argument>
                                <argument>-m</argument>
                                <argument>512m</argument>
                                <argument>${solr.force}</argument>
                            </arguments>
                            <async>true</async>
                            <asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop-solr</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${solr.script.dir}${solr.script.file}</executable>
                            <arguments>
                                <argument>stop</argument>
                                <argument>-p</argument>
                                <argument>${solr.port}</argument>
                            </arguments>
                            <async>true</async>
                            <asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.servicemix.tooling</groupId>
                <artifactId>depends-maven-plugin</artifactId>
                <version>1.4.0</version>
                <executions>
                    <execution>
                        <id>generate-depends-file</id>
                        <goals>
                            <goal>generate-depends-file</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.8.1</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.5.2</version>
                <configuration>
                    <includes>
                        <include>**/*Suite.java</include>
                    </includes>
                    <argLine>${jacoco.argline}</argLine>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
