<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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.github.mstream-trader</groupId>
        <artifactId>simulation-parent</artifactId>
        <version>1.13</version>
    </parent>

    <artifactId>simulation-functional-tests</artifactId>

    <properties>
        <maven.version>3.0</maven.version>
        <java.version>1.8</java.version>
        <service.port>8080</service.port>
        <service.debug.port>5005</service.debug.port>
        <mock.server.port>80</mock.server.port>
        <mock.proxy.port>90</mock.proxy.port>
        <zookeeper.port>2181</zookeeper.port>
        <docker.server.host>${docker.host.address}</docker.server.host>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.15.7</version>
                <configuration>
                    <images>
                        <image>
                            <alias>service</alias>
                            <name>
                                mstream/trader-${serviceName}:${project.version}
                            </name>
                            <run>
                                <links>
                                    <link>mock:data-feed</link>
                                    <link>zookeeper:zookeeper</link>
                                </links>
                                <env>
                                    <zookeeper.port>${zookeeper.port}
                                    </zookeeper.port>
                                </env>
                                <labels>
                                    <version>${project.version}</version>
                                </labels>
                                <ports>
                                    <port>${service.port}:${service.port}</port>
                                    <port>
                                        ${service.debug.port}:${service.debug.port}
                                    </port>
                                </ports>
                                <cmd>
                                    java
                                    -DZK_CONNECTION_STRING=zookeeper:${zookeeper.port}
                                    -jar /opt/simulation.jar
                                    --port ${service.port}
                                </cmd>
                                <wait>
                                    <http>
                                        <url>
                                            http://${docker.server.host}:${service.port}/monitoring/version
                                        </url>
                                        <method>GET</method>
                                        <status>200</status>
                                    </http>
                                    <time>10000</time>
                                </wait>
                                <log>
                                </log>
                            </run>
                        </image>
                        <image>
                            <alias>mock</alias>
                            <name>jamesdbloom/mockserver</name>
                            <run>
                                <ports>
                                    <port>
                                        ${mock.server.port}:${mock.server.port}
                                    </port>
                                    <port>
                                        ${mock.proxy.port}:${mock.proxy.port}
                                    </port>
                                </ports>
                                <wait>
                                    <tcp>
                                        <ports>
                                            <port>${mock.server.port}</port>
                                            <port>${mock.proxy.port}</port>
                                        </ports>
                                    </tcp>
                                    <time>10000</time>
                                </wait>
                                <cmd>/opt/mockserver/run_mockserver.sh -logLevel
                                    INFO -serverPort ${mock.server.port}
                                    -proxyPort ${mock.proxy.port}
                                </cmd>
                            </run>
                        </image>
                        <image>
                            <alias>zookeeper</alias>
                            <name>zookeeper:3.4.9</name>
                            <run>
                                <ports>
                                    <port>
                                        ${zookeeper.port}:${zookeeper.port}
                                    </port>
                                </ports>
                                <wait>
                                    <tcp>
                                        <ports>
                                            <port>${zookeeper.port}</port>
                                        </ports>
                                    </tcp>
                                    <time>10000</time>
                                </wait>
                            </run>
                        </image>
                    </images>
                </configuration>
                <executions>
                    <execution>
                        <id>start</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                            <goal>remove</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <includes>
                        <include>**/TestRunner.java</include>
                    </includes>
                    <systemPropertyVariables>
                        <SERVICE_ADDRESS>${docker.server.host}</SERVICE_ADDRESS>
                        <SERVICE_PORT>${service.port}</SERVICE_PORT>
                        <MOCK_ADDRESS>${docker.server.host}</MOCK_ADDRESS>
                        <MOCK_SERVER_PORT>${mock.server.port}</MOCK_SERVER_PORT>
                        <MOCK_PROXY_PORT>${mock.proxy.port}</MOCK_PROXY_PORT>
                        <ZK_CONNECTION_STRING>
                            ${docker.server.host}:${zookeeper.port}
                        </ZK_CONNECTION_STRING>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.github.mstream-trader</groupId>
            <artifactId>simulation</artifactId>
            <version>1.13</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.mstream-trader</groupId>
            <artifactId>commons-test</artifactId>
            <version>1.13</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.github.mstream-trader</groupId>
                    <artifactId>commons-utils</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.github.mstream-trader</groupId>
                    <artifactId>commons-config</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.github.mstream-trader</groupId>
            <artifactId>commons-config</artifactId>
            <version>1.16</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.mstream-trader</groupId>
            <artifactId>commons-utils</artifactId>
            <version>1.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.8.3</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.11.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.5.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>19.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.21</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>3.0.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mock-server</groupId>
            <artifactId>mockserver-client-java</artifactId>
            <version>3.10.4</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.scala-lang</groupId>
                    <artifactId>scala-library</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.code.findbugs</groupId>
                    <artifactId>jsr305</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-buffer</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-codec</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-codec-http</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-codec-socks</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-handler</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-transport</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-framework</artifactId>
            <version>2.11.0</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.4</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>4.1.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-guice</artifactId>
            <version>1.2.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>3.0.0</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpclient</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.23</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
