<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source.
  ~
  ~ Copyright 2021 Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>testsuite</artifactId>
        <groupId>org.jboss.resteasy.microprofile</groupId>
        <version>3.0.0.Final</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>microprofile-rest-client-tck</artifactId>
    <name>RESTEasy MicroProfile: MicroProfile Rest Client TCK</name>
    <packaging>jar</packaging>

    <properties>
        <skip.mp.tck>false</skip.mp.tck>
        <tck.timeout.offset>90000</tck.timeout.offset>
        <wiremock.module.path>${jboss.home}/modules/org/wiremock/main/</wiremock.module.path>
    </properties>

    <dependencies>
        <!-- REST Client implementation-->
        <dependency>
            <groupId>org.jboss.resteasy.microprofile</groupId>
            <artifactId>microprofile-rest-client</artifactId>
            <scope>test</scope>
            <version>${version.resteasy.microprofile.testsuite}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy.microprofile</groupId>
            <artifactId>microprofile-rest-client-base</artifactId>
            <scope>test</scope>
            <version>${version.resteasy.microprofile.testsuite}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client-api</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-core-spi</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-core</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>test</scope>
        </dependency>

        <!-- Config Implementation -->
        <dependency>
            <groupId>io.smallrye.config</groupId>
            <artifactId>smallrye-config</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Microprofile TCK tests -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- It's odd, but JUnit is also required. However, it needs to be defined after TestNG -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.eclipse.microprofile.rest.client</groupId>
            <artifactId>microprofile-rest-client-tck</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- TCK Support  -->
        <dependency>
            <groupId>jakarta.enterprise</groupId>
            <artifactId>jakarta.enterprise.cdi-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wiremock</groupId>
            <artifactId>wiremock</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.testng</groupId>
            <artifactId>arquillian-testng-container</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-json-p-provider</artifactId>
            <scope>test</scope>
            <version>${version.resteasy.testsuite}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-multipart-provider</artifactId>
            <scope>test</scope>
            <version>${version.resteasy.testsuite}</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld.se</groupId>
            <artifactId>weld-se-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.json</groupId>
            <artifactId>jakarta.json-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.parsson</groupId>
            <artifactId>parsson</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- required to jsonb used in tests -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-json-binding-provider</artifactId>
            <scope>test</scope>
            <version>${version.resteasy.testsuite}</version>
        </dependency>

        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly.arquillian</groupId>
            <artifactId>wildfly-arquillian-container-managed</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>uk.co.automatictester</groupId>
                <artifactId>wiremock-maven-plugin</artifactId>
                <version>7.3.0</version>
                <executions>
                    <execution>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <skip>${skip.mp.tck}</skip>
                            <dir>target/classes</dir>
                            <params>--port=8765 --disable-banner=true</params>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.wiremock</groupId>
                        <artifactId>wiremock</artifactId>
                        <version>${version.org.wiremock}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <configuration>
                    <overwrite-provisioned-server>true</overwrite-provisioned-server>
                </configuration>
                <executions>
                    <execution>
                        <id>add-wiremock-module</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>execute-commands</goal>
                        </goals>
                        <configuration>
                            <offline>true</offline>
                            <jboss-home>${jboss.home}</jboss-home>
                            <stdout>${jboss.home}/configuration/standalone/log/wildfly-wiremock.log</stdout>
                            <system-properties>
                                <beansxml.path>${basedir}${file.separator}config${file.separator}wildfly${file.separator}beans.xml</beansxml.path>
                            </system-properties>
                            <scripts>
                                <script>${basedir}${file.separator}config${file.separator}wildfly${file.separator}wiremock.cli</script>
                            </scripts>
                        </configuration>
                    </execution>
                    <execution>
                        <id>mp-server-provisioning</id>
                        <goals>
                            <goal>provision</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-module-xml</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${wiremock.module.path}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>config/wildfly/</directory>
                                    <includes>
                                        <include>module.xml</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install-as-module-wiremock</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeGroupIds>org.wiremock,org.apache.httpcomponents.client5,org.apache.httpcomponents.core5,junit,org.eclipse.jetty</includeGroupIds>
                            <stripVersion>true</stripVersion>
                            <outputDirectory>${wiremock.module.path}</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>install-wiremock</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.wiremock</groupId>
                                    <artifactId>wiremock</artifactId>
                                </artifactItem>
                            </artifactItems>
                            <stripVersion>true</stripVersion>
                            <outputDirectory>${wiremock.module.path}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>${skip.mp.tck}</skip>
                    <systemPropertyVariables>
                        <org.eclipse.microprofile.rest.client.tck.timeoutCushion>${tck.timeout.offset}
                        </org.eclipse.microprofile.rest.client.tck.timeoutCushion>
                        <test.url>http://localhost:8080</test.url>
                    </systemPropertyVariables>
                    <forkCount>1</forkCount>
                    <reuseForks>false</reuseForks>
                    <runOrder>alphabetical</runOrder>
                    <dependenciesToScan>
                        <dependency>org.eclipse.microprofile.rest.client:microprofile-rest-client-tck</dependency>
                    </dependenciesToScan>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>