<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Distribution License v. 1.0, which is available at
    http://www.eclipse.org/org/documents/edl-v10.php.

    SPDX-License-Identifier: BSD-3-Clause

-->

<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">

    <parent>
        <groupId>org.glassfish.metro</groupId>
        <artifactId>ws-test-harness</artifactId>
        <version>2.3.3</version>
        <relativePath>../pom.xml</relativePath>
    </parent>


    <modelVersion>4.0.0</modelVersion>
    <artifactId>harness-lib</artifactId>

    <name>WS Test Harness Library</name>

    <properties>
        <test.options />
        <!-- to pass extra JVM args to harness -->
        <harness.extra.jvm.arg />
    </properties>

    <dependencies>
        <dependency>
          <groupId>com.sun.activation</groupId>
          <artifactId>jakarta.activation</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.ws</groupId>
            <artifactId>jakarta.xml.ws-api</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.jws</groupId>
            <artifactId>jakarta.jws-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.istack</groupId>
            <artifactId>istack-commons-runtime</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sun.istack</groupId>
            <artifactId>istack-commons-test</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-junit</artifactId>
        </dependency>
        <dependency>
            <groupId>args4j</groupId>
            <artifactId>args4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache-extras.beanshell</groupId>
            <artifactId>bsh</artifactId>
        </dependency>
        <dependency>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-core-uberjar</artifactId>
        </dependency>
        <dependency>
            <groupId>org.relaxng</groupId>
            <artifactId>jing</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-clean</id>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>${project.build.directory}</directory>
                                </fileset>
                                <fileset>
                                    <directory>src/test/testcases</directory>
                                    <includes>
                                        <include>**/work/**</include>
                                    </includes>
                                    <followSymlinks>false</followSymlinks>
                                </fileset>
                            </filesets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-transport</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>target/transport</outputDirectory>
                            <silent>false</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.sun.xml.ws</groupId>
                                    <artifactId>jaxws-local-transport</artifactId>
                                    <version>${jaxws-ri.version}</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                            <stripVersion>true</stripVersion>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <configuration>
                    <target>
                        <delete dir="target/surefire-reports" />

                        <java classname="com.sun.xml.ws.test.Main" fork="true" classpathref="maven.test.classpath" failonerror="true">
                            <jvmarg line="${harness.extra.jvm.arg} ${harness.extra.jvm.arg.internal} -Dign=nn"/>
                            <!--<jvmarg line="-Djava.endorsed.dirs=${basedir}/target/endorsed" />-->
                            <!--<jvmarg line="- -upgrade-module-path=${basedir}/target/endorsed ${harness.extra.jvm.arg}" />-->
                            <!--<jvmarg line="-Dharness.deploy.timeout=60000 -Dharness.useSSL=true -Dharness.ssl.home=${project.basedir}/src/test/certs" />-->
                            <!--<jvmarg line="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=6000" />-->
                            <arg line="${image}" />

                            <arg line="${test.options}" />

                            <arg value="-report" />
                            <arg path="target/surefire-reports" />

<!--                            <arg value="-tomcat-local" />
                            <arg path="/space/sources/ws-test-harness/apache-tomcat-7.0.42" />-->

                            <arg value="-transport" />
                            <arg path="target/transport/jaxws-local-transport.jar" />

                            <!-- test data -->
                            <arg value="-r" />
                            <arg path="src/test/${testcases}" />

                        </java>
                    </target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>jaxws-ri</id>
            <activation>
                <property>
                    <!-- run tests using jaxws-ri -->
                    <name>!metro-image</name>
                </property>
            </activation>
            <properties>
                <image>-cp:jaxws-image target/jaxws-ri-image/jaxws-ri</image>
                <testcases>testcases/jaxws</testcases>
                <harness.extra.jvm.arg.internal>-Djdk.util.jar.enableMultiRelease=force</harness.extra.jvm.arg.internal>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>target/endorsed</outputDirectory>
                                    <silent>false</silent>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>jakarta.xml.bind</groupId>
                                            <artifactId>jakarta.xml.bind-api</artifactId>
                                            <version>${jakarta.xml.bind-api.version}</version>
                                            <type>jar</type>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>jakarta.jws</groupId>
                                            <artifactId>jakarta.jws-api</artifactId>
                                            <version>${jakarta.jws-api.version}</version>
                                            <type>jar</type>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>jakarta.xml.soap</groupId>
                                            <artifactId>jakarta.xml.soap-api</artifactId>
                                            <version>${jakarta.xml.soap-api.version}</version>
                                            <type>jar</type>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>jakarta.xml.ws</groupId>
                                            <artifactId>jakarta.xml.ws-api</artifactId>
                                            <version>${jakarta.xml.ws-api.version}</version>
                                            <type>jar</type>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                            <execution>
                                <id>unpack-image</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>target/jaxws-ri-image</outputDirectory>
                                    <silent>false</silent>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>com.sun.xml.ws</groupId>
                                            <artifactId>jaxws-ri</artifactId>
                                            <version>${jaxws-ri.version}</version>
                                            <type>zip</type>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <phase>test</phase>
                                <id>run-tests</id>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>metro</id>
            <activation>
                <property>
                    <!-- run tests using metro -->
                    <name>metro-image</name>
                </property>
            </activation>
            <properties>
                <image>-cp:wsit-image target/metro-image/metro</image>
                <testcases>testcases</testcases>
                <harness.extra.jvm.arg.internal>-DWSIT_HOME=${project.basedir}/src/test/certs -Djdk.util.jar.enableMultiRelease=force</harness.extra.jvm.arg.internal>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>target/endorsed</outputDirectory>
                                    <silent>false</silent>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.glassfish.metro</groupId>
                                            <artifactId>webservices-api</artifactId>
                                            <version>${metro.version}</version>
                                            <type>jar</type>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                            <execution>
                                <id>unpack-image</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>target/metro-image</outputDirectory>
                                    <silent>false</silent>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.glassfish.metro</groupId>
                                            <artifactId>metro-standalone</artifactId>
                                            <version>${metro.version}</version>
                                            <type>zip</type>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <phase>test</phase>
                                <id>run-tests</id>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
