<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You 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/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.apache.tomee</groupId>
    <artifactId>microprofile-tck</artifactId>
    <version>11.0.0-M1</version>
  </parent>

  <artifactId>microprofile-rest-client-tck</artifactId>
  <name>TomEE :: TCK :: MicroProfile Rest Client TCK</name>

  <properties>
    <wiremock.version>3.13.1</wiremock.version>
    <!-- WireMock 3.x and the MP Rest Client TCK's SSE HttpSseServer run on Jetty 11. -->
    <version.jetty11>11.0.24</version.jetty11>
  </properties>

  <build>
    <plugins>

      <plugin>
        <groupId>uk.co.automatictester</groupId>
        <artifactId>wiremock-maven-plugin</artifactId>
        <version>7.3.0</version>
        <dependencies>
          <dependency>
            <groupId>org.wiremock</groupId>
            <artifactId>wiremock-standalone</artifactId>
            <version>${wiremock.version}</version>
          </dependency>
        </dependencies>
        <configuration>
          <dir>target/classes</dir>
          <params>--port=8765 --disable-banner=true</params>
        </configuration>
        <executions>
          <execution>
            <id>start-wiremock</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
          <execution>
            <id>stop-wiremock</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <dependenciesToScan>
                <dependency>org.eclipse.microprofile.rest.client:microprofile-rest-client-tck</dependency>
              </dependenciesToScan>
              <excludes>
                <!-- JSONB tests run in a separate solo execution below -->
                <exclude>org.eclipse.microprofile.rest.client.tck.jsonb.*</exclude>
                <!-- SSE reactive streams tests pass locally but fail on ASF CI (Linux) -->
                <exclude>org.eclipse.microprofile.rest.client.tck.sse.BasicReactiveStreamsTest</exclude>
              </excludes>
            </configuration>
          </execution>
          <execution>
            <id>mp-clienb-jsonb-solo</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <suiteXmlFiles>
                <suiteXmlFile>tck-suite-jsonb-solo.xml</suiteXmlFile>
              </suiteXmlFiles>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>mp-tck-all</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
              <execution>
                <id>tomee-plus</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <systemPropertyVariables>
                    <arquillian.launch>tomee-plus</arquillian.launch>
                  </systemPropertyVariables>
                </configuration>
              </execution>
              <execution>
                <id>tomee-plume</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <systemPropertyVariables>
                    <arquillian.launch>tomee-plume</arquillian.launch>
                  </systemPropertyVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <!--
    The TomEE reactor manages jetty-server/http/io/security/util to Jetty 12
    (${version.jetty}). WireMock 3.x pulls the rest of its Jetty stack
    (jetty-servlet, jetty-servlets, jetty-webapp, ...) at Jetty 11, so the reactor's
    management splits WireMock into a mixed 11/12 Jetty. The TCK's SSE HttpSseServer
    then loads jetty-servlet:11's org.eclipse.jetty.servlet.ServletHandler, whose
    superclass org.eclipse.jetty.server.handler.ScopedHandler was removed in Jetty 12,
    and the SSE server dies with NoClassDefFoundError. Override these test-scope
    artifacts back to the Jetty 11 line WireMock uses so the whole stack is coherent.
  -->
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-server</artifactId>
        <version>${version.jetty11}</version>
      </dependency>
      <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-http</artifactId>
        <version>${version.jetty11}</version>
      </dependency>
      <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-io</artifactId>
        <version>${version.jetty11}</version>
      </dependency>
      <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-security</artifactId>
        <version>${version.jetty11}</version>
      </dependency>
      <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-util</artifactId>
        <version>${version.jetty11}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.eclipse.microprofile.rest.client</groupId>
      <artifactId>microprofile-rest-client-api</artifactId>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>javax.inject</groupId>
          <artifactId>javax.inject</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

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

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>apache-tomee</artifactId>
      <version>${project.version}</version>
      <type>zip</type>
      <classifier>microprofile</classifier>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>7.10.2</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.wiremock</groupId>
      <artifactId>wiremock</artifactId>
      <version>${wiremock.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-rs-mp-client</artifactId>
      <version>${version.cxf}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>org.glassfish.jaxb</groupId>
          <artifactId>jaxb-xjc</artifactId>
        </exclusion>
        <exclusion>
          <groupId>jakarta.json</groupId>
          <artifactId>jakarta.json-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>jakarta.json.bind</groupId>
          <artifactId>jakarta.json.bind-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>jakarta.ws.rs</groupId>
          <artifactId>jakarta.ws.rs-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>jakarta.annotation</groupId>
          <artifactId>jakarta.annotation-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>


    <dependency>
      <groupId>org.apache.johnzon</groupId>
      <artifactId>johnzon-core</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>arquillian-tomee-remote</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.httpcomponents.core5</groupId>
      <artifactId>httpcore5</artifactId>
      <version>5.4.2</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

</project>
