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

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2011, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->

<project>
  
  <!-- ================================================================== -->
  <!-- Initialization                                                     -->
  <!-- ================================================================== -->
  
  <target name="tests-prepare" depends="prepare">
    
    <!-- Define jboss.home -->
    <condition property="jboss.home" value="${jboss701.home}">
      <equals arg1="${jbossws.integration.target}" arg2="jboss701"/>
    </condition>
    <condition property="jboss.home" value="${jboss702.home}">
      <equals arg1="${jbossws.integration.target}" arg2="jboss702"/>
    </condition>
    <condition property="jboss.home" value="${jboss710.home}">
      <equals arg1="${jbossws.integration.target}" arg2="jboss710"/>
    </condition>
    <condition property="jboss.home" value="${jboss711.home}">
      <equals arg1="${jbossws.integration.target}" arg2="jboss711"/>
    </condition>
    <condition property="jboss.home" value="${jboss712.home}">
      <equals arg1="${jbossws.integration.target}" arg2="jboss712"/>
    </condition>
    
    <!-- Verify required properties that must be set before this file is imported -->
    <fail message="Tests output dir not set." unless="tests.output.dir"/>

    <!-- appclient patch -->
    <copy
      file="${basedir}/tests/etc/appclient/${jbossws.integration.target}/appclient-ws.xml"
      tofile="${jboss.home}/appclient/configuration/appclient-ws.xml"
      failonerror="false"
      overwrite="true"
      verbose="true"
    />

    <!-- Verify availabililty of tools.jar -->
    <condition property="tools.jar" value="${java.home}/lib/tools.jar">
      <available file="${java.home}/lib/tools.jar"/>
    </condition>
    <condition property="tools.jar" value="${java.home}/../lib/tools.jar">
      <available file="${java.home}/../lib/tools.jar"/>
    </condition>
    <!-- [JBWS-2113] tools.jar not available on Mac OS X -->
    <condition property="tools.jar" value="${java.home}/../Classes/classes.jar">
      <available file="${java.home}/../Classes/classes.jar"/>
    </condition>
    <fail message="Not available: ${java.home}/lib/tools.jar, ${java.home}/../lib/tools.jar" unless="tools.jar"/>
    
    <!-- Use -Ddebug=true for remote debugging -->
    <condition property="remote.debug.line" value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005">
      <isset property="debug"/>
    </condition>
    <condition property="remote.debug.line" value="">
      <not>
        <isset property="debug"/>
      </not>
    </condition>
    
    <!-- Set a hostname property based on COMPUTERNAME for win32, HOSTNAME
    otherwise and initialize the node0/node1 cluster hostnames to localhost
    and ${hostname} by default. If you cannot route multicast traffic between
    localhost and hostname, then you need to specify node0 and node1 binding
    in the local.properties that can in order to be able to run the clustering
    tests.
    -->
    <property environment="env"/>
    <condition property="hostname" value="${env.COMPUTERNAME}">
      <os family="windows"/>
    </condition>
    <condition property="hostname" value="${env.HOSTNAME}">
      <not>
        <os family="windows"/>
      </not>
    </condition>
    
    <!-- node0 defaults -->
    <property name="node0" value="${jboss.bind.address}"/>
    <property name="node0.http.url" value="http://${node0}:8080"/>
    <property name="node0.jndi.url" value="jnp://${node0}:1099"/>
    <property name="node0.hajndi.url" value="jnp://${node0}:1100"/>
    
    <mkdir dir="${tests.output.dir}"/>
    <delete file="${tests.output.dir}/test.log" failonerror="false"/>
    
    <property name="jboss.lib" value="${jboss.home}/lib"/>
  	
    <!-- Java Endorsed -->
    <condition property="endorsed.dirs" value="${jboss.home}/modules/javax/xml/ws/api/main/">
      <isset property="jboss.home"/>
    </condition>
    
    <!-- JBossWS Native Core version -->
    <condition property="jbossws-native-core.default-filename" value="4.0.1.GA">
      <equals arg1="${jbossws.integration.target}" arg2="jboss710"/>
    </condition>
    <condition property="jbossws-native-core.default-filename" value="4.0.2.GA">
      <equals arg1="${jbossws.integration.target}" arg2="jboss711"/>
    </condition>

    <echo/>
    <echo message="-----------------------------------------------"/>
    <echo message="jboss.home   = ${jboss.home}"/>
    <echo message="excludesfile = ${excludesfile}"/>
    <echo message="java.home    = ${java.home}"/>
    <echo message="jboss.bind   = ${jboss.bind.address}"/>
    <echo message="-----------------------------------------------"/>
    
    <tstamp>
      <format property="build.id" pattern="yyyyMMddHHmm"/>
    </tstamp>
  </target>
  
  <target name="tests-classpath" depends="tests-classpath-jboss710,tests-classpath-jboss700">
    <path id="tests.javac.classpath">
      <path refid="ws.stack.classpath"/>
      <path refid="integration.target.javac.classpath"/>
    </path>
    <path id="tests.client.classpath">
      <path refid="ws.stack.classpath"/>
      <path refid="integration.target.client.classpath"/>
    </path>
  </target>
  
  <target name="tests-classpath-jboss700" depends="tests-prepare" if="jbossws.integration.jboss700">
    
    <path id="integration.target.javac.classpath">
      <fileset dir="${jboss.home}/modules/javax/activation/api/main/">
        <include name="activation-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/mail/api/main/">
        <include name="mail-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/common-core/main/">
        <include name="jboss-common-core-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/logging/main/">
        <include name="jboss-logging-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/ejb/api/main/">
        <include name="jboss-ejb-api_3.1_spec-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/ejb3/main/">
        <include name="jboss-ejb3-ext-api-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/servlet/api/main/">
        <include name="jboss-servlet-api_3.0_spec-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/annotation/api/main/">
        <include name="jboss-annotations-api_1.1_spec-*.jar"/>
      </fileset>
    </path>
    
    <!-- 
    The 's.client.classpath' contains jars that are available in the target container's client directory.
    There jars apply to all supported stacks. It MUST NOT contains jars from a local thirdparty dir.
    
    The 'ws.stack.classpath' contains jars that come with a specific stack distribution.
    The 's.extra.classpath' contains stack specific jars that are needed to run the stack specific tests.
    -->
    <path id="integration.target.client.classpath">
      <pathelement location="${thirdparty.dir}/jbossws-${jbossws.integration.target}-tests-integration.jar"/> <!-- included from thirdparty local dir as it's not installed on AS -->
      <pathelement location="${thirdparty.dir}/jbossws-shared-testsuite.jar"/> <!-- included from thirdparty local dir as it's not installed on AS -->
      <pathelement location="${thirdparty.dir}/jnp-client.jar"/> <!-- included from thirdparty local dir as it's not installed on AS -->
      <pathelement location="${jboss.home}/jboss-modules.jar"/>
      <fileset dir="${jboss.home}/modules/org/jboss/logging/main/">
        <include name="jboss-logging-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/as/controller/main/">
        <include name="jboss-as-controller-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/as/controller-client/main/">
        <include name="jboss-as-controller-client-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/as/server/main/">
        <include name="jboss-as-server-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/as/protocol/main/">
        <include name="jboss-as-protocol-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/dmr/main/">
        <include name="jboss-dmr-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/marshalling/main/">
        <include name="jboss-marshalling-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/slf4j/main/">
        <include name="slf4j-api-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/slf4j/jcl-over-slf4j/main/">
        <include name="jcl-over-slf4j-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/slf4j/impl/main/">
        <include name="slf4j-jboss-logmanager-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/logmanager/main/">
        <include name="jboss-logmanager-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/apache/log4j/main/">
        <include name="log4j-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/mail/api/main/">
        <include name="mail-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/servlet/api/main/">
        <include name="jboss-servlet-api_3.0_spec-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/threads/main/">
        <include name="jboss-threads-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/picketbox/main/">
        <include name="picketbox-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/ejb/api/main/">
        <include name="jboss-ejb-api_3.1_spec-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/apache/xerces/main/">
        <include name="xercesImpl-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/common-core/main/">
        <include name="jboss-common-core-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/javassist/main/">
        <include name="javassist-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/security/jacc/api/main/">
        <include name="jboss-jacc-api*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/remoting3/main/">
        <include name="jboss-remoting-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/sasl/main/">
        <include name="jboss-sasl-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/apache/xalan/main/">
        <include name="serializer-*.jar"/>
        <include name="xalan-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/xnio/main/">
        <include name="xnio-api-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/xnio/nio/main/">
        <include name="xnio-nio-*.jar"/>
      </fileset>
      <pathelement location="${tools.jar}"/>
    </path>
  </target>


  <target name="tests-classpath-jboss710" depends="tests-prepare" if="jbossws.integration.jboss710">
    
    <path id="integration.target.javac.classpath">
      <fileset dir="${jboss.home}/modules/javax/activation/api/main/">
        <include name="activation-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/mail/api/main/">
        <include name="mail-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/common-core/main/">
        <include name="jboss-common-core-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/logging/main/">
        <include name="jboss-logging-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/ejb/api/main/">
        <include name="jboss-ejb-api_3.1_spec-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/ejb3/main/">
        <include name="jboss-ejb3-ext-api-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/servlet/api/main/">
        <include name="jboss-servlet-api_3.0_spec-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/annotation/api/main/">
        <include name="jboss-annotations-api_1.1_spec-*.jar"/>
      </fileset>
    </path>
    
    <!-- 
    The 's.client.classpath' contains jars that are available in the target container's client directory.
    There jars apply to all supported stacks. It MUST NOT contains jars from a local thirdparty dir.
    
    The 'ws.stack.classpath' contains jars that come with a specific stack distribution.
    The 's.extra.classpath' contains stack specific jars that are needed to run the stack specific tests.
    -->
    <path id="integration.target.client.classpath">
      <pathelement location="${thirdparty.dir}/jboss-as-webservices-tests-integration.jar"/> <!-- included from thirdparty local dir as it's not installed on AS -->
      <pathelement location="${thirdparty.dir}/jbossws-shared-testsuite.jar"/> <!-- included from thirdparty local dir as it's not installed on AS -->
      <pathelement location="${thirdparty.dir}/jnp-client.jar"/> <!-- included from thirdparty local dir as it's not installed on AS -->
      <pathelement location="${jboss.home}/jboss-modules.jar"/>
      <fileset dir="${jboss.home}/modules/org/jboss/logging/main/">
        <include name="jboss-logging-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/as/controller/main/">
        <include name="jboss-as-controller-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/as/controller-client/main/">
        <include name="jboss-as-controller-client-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/as/server/main/">
        <include name="jboss-as-server-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/as/protocol/main/">
        <include name="jboss-as-protocol-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/dmr/main/">
        <include name="jboss-dmr-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/marshalling/main/">
        <include name="jboss-marshalling-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/slf4j/main/">
        <include name="slf4j-api-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/slf4j/jcl-over-slf4j/main/">
        <include name="jcl-over-slf4j-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/slf4j/impl/main/">
        <include name="slf4j-jboss-logmanager-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/logmanager/main/">
        <include name="jboss-logmanager-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/apache/log4j/main/">
        <include name="log4j-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/mail/api/main/">
        <include name="mail-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/servlet/api/main/">
        <include name="jboss-servlet-api_3.0_spec-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/transaction/api/main/">
        <include name="jboss-transaction-api_1.1_spec-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/threads/main/">
        <include name="jboss-threads-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/picketbox/main/">
        <include name="picketbox-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/ejb/api/main/">
        <include name="jboss-ejb-api_3.1_spec-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/ejb-client/main/">
        <include name="jboss-ejb-client-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/apache/xerces/main/">
        <include name="xercesImpl-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/common-core/main/">
        <include name="jboss-common-core-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/javassist/main/">
        <include name="javassist-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/javax/security/jacc/api/main/">
        <include name="jboss-jacc-api*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/remoting3/main/">
        <include name="jboss-remoting-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/marshalling/river/main/">
        <include name="jboss-marshalling-river-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/remoting3/remoting-jmx/main/">
        <include name="remoting-jmx-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/sasl/main/">
        <include name="jboss-sasl-*.jar"/>
      </fileset>
      <!-- START ## jaxrpc tests ## -->
      <fileset dir="${jboss.home}/modules/org/jboss/netty/main/">
        <include name="netty-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/xb/main/">
        <include name="jbossxb-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/ws/native/jbossws-native-core/main/">
        <include name="jbossws-native-core-${jbossws-native-core.filename}.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/ws/native/jbossws-native-core/main/">
        <include name="jbossws-native-core.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/ws/native/jbossws-native-core/main/">
        <include name="jbossws-native-core-${jbossws-native-core.default-filename}.jar"/>
      </fileset>
      <!-- END ## jaxrpc tests ## -->
      <fileset dir="${jboss.home}/modules/org/apache/xalan/main/">
        <include name="serializer-*.jar"/>
        <include name="xalan-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/xnio/main/">
        <include name="xnio-api-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/xnio/nio/main/">
        <include name="xnio-nio-*.jar"/>
      </fileset>
      <fileset dir="${jboss.home}/modules/org/jboss/remote-naming/main/">
        <include name="jboss-remote-naming-*.jar"/>
      </fileset>
      <pathelement location="${tools.jar}"/>
    </path>
  </target>
	  
  <!-- ================================================================== -->
  <!-- Compiling                                                          -->
  <!-- ================================================================== -->
  
  <macrodef name="macro-compile-classes">
    <attribute name="excludesfile"/>
    <attribute name="srcdir"/>
    <sequential>
      <mkdir dir="${tests.output.dir}/test-classes"/>
      <javac destdir="${tests.output.dir}/test-classes" debug="${javac.debug}" encoding="utf-8" verbose="${javac.verbose}" deprecation="${javac.deprecation}"
        failonerror="${javac.fail.onerror}" excludesfile="${excludesfile}">
        <src path="@{srcdir}"/>
        <classpath refid="tests.javac.classpath"/>
      </javac>
    </sequential>
  </macrodef>
  
  <!-- ================================================================== -->
  <!-- Building                                                           -->
  <!-- ================================================================== -->
  
  <macrodef name="macro-copy-resources">
    <attribute name="srcdir"/>
    <sequential>
      
      <!-- copy etc -->
      <copy todir="${tests.output.dir}/test-classes">
        <fileset dir="@{srcdir}/etc">
          <include name="*.properties"/>
          <include name="tst.policy"/>
          <include name="log4j.xml"/>
        </fileset>
        <filterset>
          <filter token="jboss.bind.address" value="${node0}"/>
        </filterset>
      </copy>
      
      <!-- copy handler definitions -->
      <copy todir="${tests.output.dir}/test-classes">
        <fileset dir="@{srcdir}/java">
          <include name="**/*.xml"/>
        </fileset>
      </copy>
      
      <!-- copy non binary files -->
      <copy todir="${tests.output.dir}/test-resources">
        <fileset dir="@{srcdir}/resources">
          <include name="**/*.wsdl"/>
          <include name="**/*.xml"/>
          <exclude name="jaxrpc/samples-override/**"/>
        </fileset>
        <filterset>
          <filter token="java.home" value="${java.home}"/>
          <filter token="jboss.bind.address" value="${node0}"/>
          <filter token="tests.output.dir" value="${tests.output.dir}"/>
          <filter token="wsdl-publish-location" value="${tests.output.dir}/wsdl-publish"/>
        </filterset>
      </copy>
      
      <!-- Copy binary files -->
      <copy todir="${tests.output.dir}/test-resources">
        <fileset dir="@{srcdir}/resources">
          <exclude name="**/*.wsdl"/>
          <exclude name="**/*.xml"/>
        </fileset>
      </copy>
    </sequential>
  </macrodef>
  
  <!-- ================================================================== -->
  <!-- Testing                                                            -->
  <!-- ================================================================== -->
  
  <!-- Run all unit tests and generate a report -->
  <target name="tests" depends="tests-jars" description="Run all unit tests and generate a report">
    <antcall target="tests-run-internal">
      <param name="include.wildcard" value="org/jboss/test/ws/**/*TestCase.class org/jboss/test/ws/**/*TestCaseForked.class"/>
      <param name="exclude.wildcard" value="no-wildcard-exclude-see-excludesfile"/>
      <param name="haltonfailure" value="false"/>
    </antcall>
    <antcall target="tests-report"/>
  </target>
  
  <!-- Run smoke test cases -->
  <target name="tests-smoke" depends="tests-init" description="Run smoke unit tests">
    <antcall target="tests-run-internal">
      <param name="include.wildcard" value="org/jboss/test/ws/jaxws/samples/**/*TestCase.class org/jboss/test/ws/*/smoke/**/*TestCase.class org/jboss/test/ws/*/smoke/**/*TestCaseForked.class"/>
      <!--
      According to our commit policy, haltonfailure MUST be be true for tests-smoke
      It is a prerequisite for any commit that this target passes without failure.
      -->
      <param name="haltonfailure" value="true"/>
    </antcall>
    <antcall target="tests-report"/>
  </target>
  
  <!-- Run samples test cases -->
  <target name="tests-samples" depends="tests-init" description="Run samples unit tests">
    <antcall target="tests-run-internal">
      <param name="include.wildcard" value="org/jboss/test/ws/*/samples/**/*TestCase.class"/>
      <param name="haltonfailure" value="false"/>
    </antcall>
  </target>
  
  <!-- Run integration test cases -->
  <target name="tests-integration" depends="tests-jars" description="Run integration unit tests">
    <antcall target="tests-run-internal">
      <param name="include.wildcard" value="org/jboss/test/ws/jaxws/samples/**/*TestCase.class org/jboss/test/ws/*/smoke/**/*TestCase.class"/>
      <param name="haltonfailure" value="false"/>
    </antcall>
    <antcall target="tests-report"/>
  </target>
  
  <!--
  Run a collection of unit tests.
  ant -Dtest=jaxws/samples/provider test
  -->
  <target name="test" depends="tests-init" if="test" description="Run all unit tests in a given directory">
    <antcall target="tests-run-internal">
      <param name="include.wildcard" value="org/jboss/test/ws/${test}/**/*TestCase.class"/>
      <param name="exclude.wildcard" value="no-wildcard-exclude-see-excludesfile"/>
      <param name="haltonfailure" value="false"/>
    </antcall>
  </target>
  
  <!-- Common test target -->
  <target name="tests-run-internal" depends="tests-init">
    <mkdir dir="${tests.output.dir}/test-reports"/>
    <junit printsummary="yes" showoutput="yes" dir="${tests.output.dir}" haltonfailure="${haltonfailure}">
      <jvmarg value="-Djava.security.manager"/>
      <jvmarg value="-ea"/>
      <!--jvmarg value="-Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true"/>
      <jvmarg value="-Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true"/-->
      
      <sysproperty key="jdk.home" value="${env.JAVA_HOME}"/>
      <sysproperty key="log4j.output.dir" value="${tests.output.dir}"/>
      <sysproperty key="appclient.output.dir" value="${tests.output.dir}/appclient-logs"/>
      <sysproperty key="client.scenario" value="${client.scenario}"/>
      <sysproperty key="interop" value="${interop}"/>
      <sysproperty key="java.endorsed.dirs" value="${endorsed.dirs}"/>
      <sysproperty key="java.naming.provider.url" value="${node0.jndi.url}"/>
      <sysproperty key="java.protocol.handler.pkgs" value="org.jboss.net.protocol|org.jboss.vfs.protocol|org.jboss.virtual.protocol"/>
      <sysproperty key="java.security.policy" value="${tests.output.dir}/test-classes/tst.policy"/>
      <sysproperty key="jboss.home" value="${jboss.home}"/>
      <sysproperty key="jboss.bind.address" value="${node0}"/>
      <sysproperty key="jbossws.integration.target" value="${jbossws.integration.target}"/>
      <sysproperty key="jbossws.deployer.authentication.username" value="${jbossws.deployer.authentication.username}"/>
      <sysproperty key="jbossws.deployer.authentication.password" value="${jbossws.deployer.authentication.password}"/>
      <sysproperty key="jmx.authentication.username" value="${jmx.authentication.username}"/>
      <sysproperty key="jmx.authentication.password" value="${jmx.authentication.password}"/>
      <sysproperty key="org.jboss.ws.testsuite.securityDomain.users.propfile" value="${tests.output.dir}/test-classes/jbossws-users.properties"/>
      <sysproperty key="org.jboss.ws.testsuite.securityDomain.roles.propfile" value="${tests.output.dir}/test-classes/jbossws-roles.properties"/>
      <sysproperty key="org.jboss.ws.wsse.keyStore" value="${tests.output.dir}/test-resources/jaxws/samples/wssecurity/wsse.keystore"/>
      <sysproperty key="org.jboss.ws.wsse.trustStore" value="${tests.output.dir}/test-resources/jaxws/samples/wssecurity/wsse.truststore"/>
      <sysproperty key="org.jboss.ws.wsse.keyStorePassword" value="jbossws"/>
      <sysproperty key="org.jboss.ws.wsse.trustStorePassword" value="jbossws"/>
      <sysproperty key="org.jboss.ws.wsse.keyStoreType" value="jks"/>
      <sysproperty key="org.jboss.ws.wsse.trustStoreType" value="jks"/>
      <sysproperty key="test.archive.directory" value="${tests.output.dir}/test-libs"/>
      <sysproperty key="test.classes.directory" value="${tests.output.dir}/test-classes"/>
      <sysproperty key="test.resources.directory" value="${tests.output.dir}/test-resources"/>
      <sysproperty key="test.username" value="${test.username}"/>
      <sysproperty key="test.password" value="${test.password}"/>
      <classpath>
        <path refid="tests.client.classpath"/>
        <pathelement location="${tests.output.dir}/test-classes"/>
      </classpath>
      <formatter type="plain" usefile="true"/>
      <formatter type="xml" usefile="true"/>
      <batchtest todir="${tests.output.dir}/test-reports" fork="true">
        <fileset dir="${tests.output.dir}/test-classes" includes="${include.wildcard}" excludes="${exclude.wildcard}"/>
      </batchtest>
    </junit>
  </target>
  
  <!--
  Run a single unit test.
  ant -Dtest=org.jboss.test.ws.jaxws.samples.provider.ProviderPayloadTestCase one-test
  -->
  <target name="one-test" depends="tests-init" if="test" description="Run a single unit test">
    <mkdir dir="${tests.output.dir}/test-reports"/>
    
    <junit printsummary="yes" showoutput="yes" dir="${tests.output.dir}">
      <jvmarg line="${remote.debug.line}"/>
      <jvmarg value="-Djava.security.manager"/>
      <jvmarg value="-ea"/>
      <!--jvmarg value="-Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true"/>
      <jvmarg value="-Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true"/-->
      
      <sysproperty key="jdk.home" value="${env.JAVA_HOME}"/>
      <sysproperty key="log4j.output.dir" value="${tests.output.dir}"/>
      <sysproperty key="appclient.output.dir" value="${tests.output.dir}/appclient-logs"/>
      <sysproperty key="client.scenario" value="${client.scenario}"/>
      <sysproperty key="interop" value="${interop}"/>
      <sysproperty key="java.endorsed.dirs" value="${endorsed.dirs}"/>
      <sysproperty key="java.naming.provider.url" value="${node0.jndi.url}"/>
      <sysproperty key="java.protocol.handler.pkgs" value="org.jboss.net.protocol|org.jboss.vfs.protocol|org.jboss.virtual.protocol"/>
      <sysproperty key="java.security.policy" value="${tests.output.dir}/test-classes/tst.policy"/>
      <sysproperty key="jboss.home" value="${jboss.home}"/>
      <sysproperty key="jboss.bind.address" value="${node0}"/>
      <sysproperty key="jbossws.integration.target" value="${jbossws.integration.target}"/>
      <sysproperty key="jbossws.deployer.authentication.username" value="${jbossws.deployer.authentication.username}"/>
      <sysproperty key="jbossws.deployer.authentication.password" value="${jbossws.deployer.authentication.password}"/>
      <sysproperty key="jmx.authentication.username" value="${jmx.authentication.username}"/>
      <sysproperty key="jmx.authentication.password" value="${jmx.authentication.password}"/>
      <!--
      http://jira.jboss.com/jira/browse/JBWS-917
      <sysproperty key="javax.net.ssl.keyStore" value="${tests.output.dir}/test-resources/jaxws/samples/wssecurity/wsse.keystore"/>
      <sysproperty key="javax.net.ssl.trustStore" value="${tests.output.dir}/test-resources/jaxws/samples/wssecurity/wsse.truststore"/>
      <sysproperty key="javax.net.ssl.keyStorePassword" value="jbossws"/>
      <sysproperty key="javax.net.ssl.trustStorePassword" value="jbossws"/>
      <sysproperty key="javax.net.ssl.keyStoreType" value="jks"/>
      <sysproperty key="javax.net.ssl.trustStoreType" value="jks"/>
      -->
      <!-- HTTPS hostname wrong:  should be <localhost> -->
      <sysproperty key="org.jboss.security.ignoreHttpsHost" value="true"/>
      <sysproperty key="org.jboss.ws.testsuite.securityDomain.users.propfile" value="${tests.output.dir}/test-classes/jbossws-users.properties"/>
      <sysproperty key="org.jboss.ws.testsuite.securityDomain.roles.propfile" value="${tests.output.dir}/test-classes/jbossws-roles.properties"/>
      <sysproperty key="org.jboss.ws.wsse.keyStore" value="${tests.output.dir}/test-resources/jaxws/samples/wssecurity/wsse.keystore"/>
      <sysproperty key="org.jboss.ws.wsse.trustStore" value="${tests.output.dir}/test-resources/jaxws/samples/wssecurity/wsse.truststore"/>
      <sysproperty key="org.jboss.ws.wsse.keyStorePassword" value="jbossws"/>
      <sysproperty key="org.jboss.ws.wsse.trustStorePassword" value="jbossws"/>
      <sysproperty key="org.jboss.ws.wsse.keyStoreType" value="jks"/>
      <sysproperty key="org.jboss.ws.wsse.trustStoreType" value="jks"/>
      <sysproperty key="test.archive.directory" value="${tests.output.dir}/test-libs"/>
      <sysproperty key="test.classes.directory" value="${tests.output.dir}/test-classes"/>
      <sysproperty key="test.resources.directory" value="${tests.output.dir}/test-resources"/>
      <sysproperty key="test.username" value="${test.username}"/>
      <sysproperty key="test.password" value="${test.password"/>
      <classpath>
        <path refid="tests.client.classpath"/>
        <pathelement location="${tests.output.dir}/test-classes"/>
      </classpath>
      <formatter type="plain" usefile="true"/>
      <formatter type="xml" usefile="true"/>
      <test todir="${tests.output.dir}/test-reports" name="${test}" fork="true"/>
    </junit>
  </target>
  
  <!-- ================================================================== -->
  <!-- Reporting                                                          -->
  <!-- ================================================================== -->
  
  <!-- Build the tests report -->
  <target name="tests-report" depends="tests-init" description="Build the tests report">
    <mkdir dir="${tests.output.dir}/test-reports"/>
    <junitreport todir="${tests.output.dir}/test-reports">
      <fileset dir="${tests.output.dir}/test-reports">
        <include name="TEST-*.xml"/>
      </fileset>
      <report format="frames" todir="${tests.output.dir}/test-reports/html"/>
    </junitreport>
    <zip destfile="${tests.output.dir}/test-report-${build.id}.zip">
      <fileset dir="${tests.output.dir}" includes="test-reports/**"/>
    </zip>
  </target>
  
  <!-- ================================================================== -->
  <!-- Cleaning                                                           -->
  <!-- ================================================================== -->
  
  <target name="tests-clean" description="Delete all generated test files.">
    <delete dir="${tests.output.dir}"/>
  </target>
  
</project>
