<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-testsuite</artifactId>
        <version>4.7.2.Final</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <properties>
        <maven.compiler.parameters>true</maven.compiler.parameters>
        <container.base.dir.managed>${project.build.directory}${file.separator}${container.qualifier.managed}</container.base.dir.managed>
        <container.base.dir.managed.encoding>${project.build.directory}${file.separator}${container.qualifier.managed.encoding}</container.base.dir.managed.encoding>
        <container.base.dir.manual.gzip>${project.build.directory}${file.separator}${container.qualifier.manual.gzip}</container.base.dir.manual.gzip>
        <container.base.dir.manual.tracing>${project.build.directory}${file.separator}${container.qualifier.manual.tracing}</container.base.dir.manual.tracing>
        <container.base.dir.manual.ssl>${project.build.directory}${file.separator}${container.qualifier.manual.ssl}</container.base.dir.manual.ssl>
        <container.base.dir.manual.ssl.wrong>${project.build.directory}${file.separator}${container.qualifier.manual.ssl.wrong}</container.base.dir.manual.ssl.wrong>
        <container.base.dir.manual.ssl.wildcard>${project.build.directory}${file.separator}${container.qualifier.manual.ssl.wildcard}</container.base.dir.manual.ssl.wildcard>
        <container.base.dir.manual.ssl.sni>${project.build.directory}${file.separator}${container.qualifier.manual.ssl.sni}</container.base.dir.manual.ssl.sni>
        <container.offset.managed>0</container.offset.managed>
        <container.offset.manual.gzip>1000</container.offset.manual.gzip>
        <container.offset.manual.tracing>2000</container.offset.manual.tracing>
        <container.offset.manual.ssl>3000</container.offset.manual.ssl>
        <container.offset.manual.ssl.wrong>4000</container.offset.manual.ssl.wrong>
        <container.offset.manual.ssl.wildcard>5000</container.offset.manual.ssl.wildcard>
        <container.offset.manual.ssl.sni>6000</container.offset.manual.ssl.sni>
        <container.offset.managed.encoding>7000</container.offset.managed.encoding>
        <container.management.port.managed>9990</container.management.port.managed><!-- keep in sync with port offset -->
        <container.management.port.manual.gzip>10990</container.management.port.manual.gzip><!-- keep in sync with port offset -->
        <container.management.port.manual.tracing>11990</container.management.port.manual.tracing><!-- keep in sync with port offset -->
        <container.management.port.manual.ssl>12990</container.management.port.manual.ssl><!-- keep in sync with port offset -->
        <container.management.port.manual.ssl.wrong>13990</container.management.port.manual.ssl.wrong><!-- keep in sync with port offset -->
        <container.management.port.manual.ssl.wildcard>14990</container.management.port.manual.ssl.wildcard><!-- keep in sync with port offset -->
        <container.management.port.manual.ssl.sni>15990</container.management.port.manual.ssl.sni><!-- keep in sync with port offset -->
        <container.management.port.managed.encoding>16990</container.management.port.managed.encoding><!-- keep in sync with port offset -->
        <container.qualifier.managed>jbossas-managed</container.qualifier.managed>
        <container.qualifier.managed.encoding>jbossas-managed-encoding</container.qualifier.managed.encoding>
        <container.qualifier.manual.gzip>jbossas-manual-gzip</container.qualifier.manual.gzip>
        <container.qualifier.manual.tracing>jbossas-manual-tracing</container.qualifier.manual.tracing>
        <container.qualifier.manual.ssl>jbossas-manual-ssl</container.qualifier.manual.ssl>
        <container.qualifier.manual.ssl.wrong>jbossas-manual-ssl-wrong</container.qualifier.manual.ssl.wrong>
        <container.qualifier.manual.ssl.wildcard>jbossas-manual-ssl-wildcard</container.qualifier.manual.ssl.wildcard>
        <container.qualifier.manual.ssl.sni>jbossas-manual-ssl-sni</container.qualifier.manual.ssl.sni>
    </properties>

    <artifactId>resteasy-integration-tests</artifactId>
    <name>RESTEasy Main testsuite: Integration tests</name>

    <profiles>
        <!--
        Name:  download
        Descr: Download WildFly
        -->
        <profile>
          <id>download</id>
          <activation>
            <property>
              <name>!server.home</name>
            </property>
          </activation>
          <build>
            <plugins>
              <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <skip>${skipTests}</skip>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.wildfly</groupId>
                                    <artifactId>wildfly-dist</artifactId>
                                    <version>${server.version}</version>
                                    <type>zip</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/test-server</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
              </plugin>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-resteasy</id>
                        <phase>generate-test-resources</phase>
                        <configuration>
                            <target>
                                <!-- Explicitly remove resteasy-spring contents as the module.xml does not reference resource jars in this case
                                     so adding jars without removing old ones basically messes up the classloader -->
                                <delete>
                                    <fileset
                                            dir="${project.build.directory}/test-server/wildfly-${server.version}/modules/system/layers/base/org/jboss/resteasy/resteasy-spring/main"
                                            includes="**/*.jar"/>
                                </delete>
                                <unzip src="../../jboss-modules/target/resteasy-jboss-modules-${project.version}.zip"
                                       dest="${project.build.directory}/test-server/wildfly-${server.version}/modules/system/layers/base"
                                       overwrite="true"/>
                                <delete dir="target/dependency-maven-plugin-markers"/>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
              </plugin>
            </plugins>
          </build>
          <properties>
            <jboss.home>${project.build.directory}/test-server/wildfly-${server.version}</jboss.home>
          </properties>
        </profile>
        <!--
            By default, ${version.resteasy.testsuite} version for RESTEasy restclient is used.
            But use.mp.from.project.profile allows to use ${project.version} version for RESTEasy restclient.
                This is useful for test runs where we test resteasy version without RESTEasy restclient available.
                In this case, tests with RESTEasy restclient are used for compatibility testing only.
        -->
        <profile>
            <id>not.use.mp.from.project.profile</id>
            <activation>
                <property>
                    <name>!ts.use.mp.from.project</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.resteasy</groupId>
                    <artifactId>resteasy-client-microprofile</artifactId>
                    <version>${version.resteasy.testsuite}</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>use.mp.from.project.profile</id>
            <activation>
                <property>
                    <name>ts.use.mp.from.project</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.resteasy</groupId>
                    <artifactId>resteasy-client-microprofile</artifactId>
                    <version>${project.version}</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>arquillian-utils</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-core-spi</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxb-provider</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-stats</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.eclipse.microprofile.config</groupId>
            <artifactId>microprofile-config-api</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>io.smallrye.config</groupId>
            <artifactId>smallrye-config</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-validator-provider</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>provided</scope>
        </dependency>

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

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson2-provider</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>provided</scope>
        </dependency>

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

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-json-binding-provider</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-atom-provider</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-cache-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-cdi</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-crypto</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-wadl</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jdk-http</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-netty4</artifactId>
            <version>${project.version}</version>
        </dependency>
        
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-wadl-undertow-connector</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-html</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-tracing-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.enterprise</groupId>
            <artifactId>jakarta.enterprise.cdi-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.jms</groupId>
            <artifactId>jboss-jms-api_2.0_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.el</groupId>
            <artifactId>jboss-el-api_3.0_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.servlet</groupId>
            <artifactId>jboss-servlet-api_4.0_spec</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpasyncclient</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
        </dependency>

        <dependency>
            <groupId>org.wildfly.extras.creaper</groupId>
            <artifactId>creaper-core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.as</groupId>
                    <artifactId>jboss-as-controller-client</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jboss.as</groupId>
                    <artifactId>jboss-as-cli</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.wildfly.extras.creaper</groupId>
            <artifactId>creaper-commands</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.wildfly</groupId>
                    <artifactId>wildfly-patching</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.wildfly.core</groupId>
            <artifactId>wildfly-cli</artifactId>
        </dependency>

        <dependency>
            <groupId>io.reactivex.rxjava2</groupId>
            <artifactId>rxjava</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-rxjava2</artifactId>
            <version>${version.resteasy.testsuite}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging-annotations</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>json-path</artifactId>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>arquillian.xml</include>
                </includes>
            </testResource>
            <testResource>
                <directory>src/test/resources</directory>
                <excludes>
                    <exclude>arquillian.xml</exclude>
                </excludes>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <configuration>
                    <skip>${skipTests}</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>initialize-basedirs</id>
                        <phase>process-test-classes</phase>
                        <configuration>
                            <target>
                                <!-- Initialize basedir for tested container by copying
                                     the original into new place.
                                     This helps to isolate the multiple running instances.
                                     One copy per each container in arquillian.xml -->

                                <delete quiet="true" dir="${container.base.dir.managed}" />
                                <copy todir="${container.base.dir.managed}" overwrite="true" failonerror="true">
                                    <fileset dir="${jboss.home}/standalone"/>
                                </copy>

                                <delete quiet="true" dir="${container.base.dir.manual.gzip}" />
                                <copy todir="${container.base.dir.manual.gzip}" overwrite="true" failonerror="true">
                                    <fileset dir="${jboss.home}/standalone"/>
                                </copy>
                                <delete quiet="true" dir="${container.base.dir.managed.encoding}" />
                                <copy todir="${container.base.dir.managed.encoding}" overwrite="true" failonerror="true">
                                    <fileset dir="${jboss.home}/standalone"/>
                                </copy>

                                <delete quiet="true" dir="${container.base.dir.manual.tracing}" />
                                <copy todir="${container.base.dir.manual.tracing}" overwrite="true" failonerror="true">
                                    <fileset dir="${jboss.home}/standalone"/>
                                </copy>

                                <delete quiet="true" dir="${container.base.dir.manual.ssl}" />
                                <copy todir="${container.base.dir.manual.ssl}" overwrite="true" failonerror="true">
                                    <fileset dir="${jboss.home}/standalone"/>
                                </copy>

                                <delete quiet="true" dir="${container.base.dir.manual.ssl.wrong}" />
                                <copy todir="${container.base.dir.manual.ssl.wrong}" overwrite="true" failonerror="true">
                                    <fileset dir="${jboss.home}/standalone"/>
                                </copy>

                                <delete quiet="true" dir="${container.base.dir.manual.ssl.wildcard}" />
                                <copy todir="${container.base.dir.manual.ssl.wildcard}" overwrite="true" failonerror="true">
                                    <fileset dir="${jboss.home}/standalone"/>
                                </copy>

                                <delete quiet="true" dir="${container.base.dir.manual.ssl.sni}" />
                                <copy todir="${container.base.dir.manual.ssl.sni}" overwrite="true" failonerror="true">
                                    <fileset dir="${jboss.home}/standalone"/>
                                </copy>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>prepare-tracing-configuration</id>
                        <phase>process-test-classes</phase>
                        <configuration>
                            <target>
                                <!-- Prepare configuration with more verbose logging for tracing tests -->
                                <copy file="${container.base.dir.manual.tracing}/configuration/standalone-full.xml"
                                      tofile="${container.base.dir.manual.tracing}/configuration/standalone-tracing.xml"/>
                                <replace
                                        file="${container.base.dir.manual.tracing}/configuration/standalone-tracing.xml">
                                    <replacetoken><![CDATA[="INFO"]]></replacetoken>
                                    <replacevalue><![CDATA[="DEBUG"]]></replacevalue>
                                </replace>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enable-elytron-full-cli</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>execute-commands</goal>
                        </goals>
                        <configuration>
                            <skip>${skipTests}</skip>
                            <jboss-home>${jboss.home}</jboss-home>
                            <offline>true</offline>
                            <scripts>
                                <script>${basedir}/../config/enable-elytron-full.cli</script>
                            </scripts>
                            <stdout>${project.build.directory}/elytron-config.out</stdout>
                            <system-properties>
                                <jboss.server.config.file.name>${jboss.server.config.file.name}</jboss.server.config.file.name>
                            </system-properties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                    <executions>

                        <!-- Re-evaluate https://issues.jboss.org/browse/RESTEASY-1884 in case we find ourselves
                             in need of adding additional execution. -->

                        <!-- default test execution -->
                        <execution>
                            <id>default-test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <configuration>
                                <systemPropertyVariables>
                                    <resteasy.microprofile.sseclient.buffersize>5</resteasy.microprofile.sseclient.buffersize>
                                </systemPropertyVariables>
                                <excludes>
                                    <!-- Tests requires excluding JsonBindingProvider-->
                                    <exclude>**/JsonBindingAnnotationsJacksonTest.java</exclude>
                                    <exclude>**/SseJsonEventTest</exclude>
                                </excludes>
                            </configuration>
                        </execution>


                        <!-- execution with excluded JSON-B -->
                        <execution>
                            <id>disable-jsonb-client</id>
                            <phase>test</phase>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <configuration>
                                <systemPropertyVariables>
                                    <resteasy.microprofile.sseclient.buffersize>5</resteasy.microprofile.sseclient.buffersize>
                                </systemPropertyVariables>
                                <includes>
                                    <include>**/JsonBindingAnnotationsJacksonTest.java</include>
                                    <include>**/SseJsonEventTest.java</include>
                                    <include>**/ValidationJaxbTest.java</include>
                                </includes>
                                <classpathDependencyExcludes>
                                    <classpathDependencyExclude>org.jboss.resteasy:resteasy-json-binding-provider</classpathDependencyExclude>
                                </classpathDependencyExcludes>

                            </configuration>
                        </execution>

                    </executions>
            </plugin>

            <!-- generate archive needed by project resteasy-quarkus-testsuite -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>assembly/assembly.xml</descriptor>
                    </descriptors>
                    <finalName>resteasy-integration-tests-${project.version}-sources</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                </configuration>
                <executions>
                    <execution>
                        <id>trigger-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <configuration>
                    <groupId>org.jboss.resteasy</groupId>
                    <artifactId>resteasy-integration-tests</artifactId>
                    <version>${project.version}</version>
                    <packaging>zip</packaging>
                    <classifier>sources</classifier>
                    <file>${project.build.directory}/resteasy-integration-tests-${project.version}-sources.zip</file>
                </configuration>
                <executions>
                    <execution>
                        <id>install-assembly-zip</id>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <phase>install</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
