blob: a5c5765b5dced0da9741d05ae7b0b62181b0ec1f [file] [log] [blame]
<!--
Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->
<property environment="env"/>
<property file="${env.APS_HOME}/config.properties"/>
<target name="test-all" depends="clean">
<basename file="${src-name}" property="server" suffix=".java"/>
<dirname file="${src-name}" property="directory"/>
<echo message="Starting Test ${directory}"/>
<basename file="${directory}" property="pkg-name"/>
<antcall target="deploy">
<param name="pkg-name" value="${pkg-name}"/>
</antcall>
<condition property="deploy_succeeded">
<available file="${env.S1AS_HOME}/domains/domain1/autodeploy/${server}.jar_deployed"/>
</condition>
<condition property="deploy_failed">
<available file="${env.S1AS_HOME}/domains/domain1/autodeploy/${server}.jar_deployFailed"/>
</condition>
<fail message="Deployment failed" if="deploy_failed"/>
<antcall target="run"/>
<echo message="Removing jar bundle ${server}.jar from autodeploy directory"/>
<antcall target="undeploy"/>
<antcall target="report"/>
</target>
<target name="clean">
<echo message="Clean from ${ant.file}"/>
<delete dir="${env.APS_HOME}/build/module/classes"/>
<delete dir="${env.APS_HOME}/build/module/archive"/>
<mkdir dir="${env.APS_HOME}/build/module/classes"/>
<mkdir dir="${env.APS_HOME}/build/module/archive"/>
</target>
<path id="classpath">
<fileset dir="${env.S1AS_HOME}/modules">
<include name="*.jar" />
</fileset>
<fileset dir="${env.APS_HOME}/lib">
<include name="reporter.jar" />
</fileset>
</path>
<target name="test-compile">
<echo message="Compiling into ${pkg-name}/${server}.class"/>
<javac srcdir="." destdir="${env.APS_HOME}/build/module/classes"
includes="${pkg-name}/*.java">
<classpath refid="classpath"/>
</javac>
</target>
<target name="compile-client">
<javac srcdir="." destdir="${env.APS_HOME}/build/module/classes"
includes="${client-src-name}">
<classpath refid="classpath"/>
</javac>
</target>
<target name="build">
<basename file="${src-name}" property="server" suffix=".java"/>
<dirname file="${src-name}" property="directory"/>
<basename file="${directory}" property="pkg-name"/>
<antcall target="test-compile"/>
<echo message="Building with package ${pkg-name}"/>
<jar destfile="${env.S1AS_HOME}/domains/domain1/autodeploy/${server}.jar"
basedir="${env.APS_HOME}/build/module/classes"
includes="${pkg-name}/**">
<metainf dir="${pkg-name}"
includes="*.xml **/*.wsdl **/*.xsd"/>
</jar>
</target>
<target name="deploy">
<antcall target="build"/>
<basename file="${src-name}" property="server" suffix=".java"/>
<waitfor maxwait="100" maxwaitunit="second">
<or>
<available file="${env.S1AS_HOME}/domains/domain1/autodeploy/${server}.jar_deployed"/>
<available file="${env.S1AS_HOME}/domains/domain1/autodeploy/${server}.jar_deployFailed"/>
</or>
</waitfor>
</target>
<target name="undeploy">
<basename file="${src-name}" property="server" suffix=".java"/>
<antcall target="autoundeploy-file">
<param name="filename" value="${server}.jar"/>
</antcall>
<condition property="undeploy_succeeded">
<available file="${env.S1AS_HOME}/domains/domain1/autodeploy/${server}.jar_undeployed"/>
</condition>
<condition property="undeploy_failed">
<available file="${env.S1AS_HOME}/domains/domain1/autodeploy/${server}.jar_undeployFailed"/>
</condition>
<fail if="undeploy_failed" message="undeployment failed"/>
</target>
<target name="autoundeploy-file">
<delete file="${env.S1AS_HOME}/domains/domain1/autodeploy/${filename}"/>
<waitfor maxwait="100" maxwaitunit="second">
<or>
<available file="${env.S1AS_HOME}/domains/domain1/autodeploy/${filename}_undeployed"/>
<available file="${env.S1AS_HOME}/domains/domain1/autodeploy/${filename}_undeployFailed"/>
</or>
</waitfor>
</target>
<target name="report" depends="internal-report-success, internal-report-failure">
<delete file="${env.S1AS_HOME}/domains/domain1/autodeploy/${class-name}_*"/>
</target>
<target name="run">
<basename file="${src-name}" property="server" suffix=".java"/>
<condition property="deploy_succeeded">
<available file="${env.S1AS_HOME}/domains/domain1/autodeploy/${server}.jar_deployed"/>
</condition>
<condition property="deploy_failed">
<available file="${env.S1AS_HOME}/domains/domain1/autodeploy/${server}.jar_deployFailed"/>
</condition>
<antcall target="prepare-client"/>
<antcall target="internal-run"/>
<!--restore the tokens back in file-->
<replace file="client/Client.java" token="${http.host}" value="HTTP_HOST"/>
<replace file="client/Client.java" token="${http.port}" value="HTTP_PORT"/>
</target>
<target name="wsdl-import">
<antcall target="configurable-wsdl-import">
<param name="host-name" value="${http.host}"/>
<param name="host-port" value="${http.port}"/>
<param name="protocol" value="http"/>
</antcall>
</target>
<target name="configurable-wsdl-import">
<tstamp>
<format property="TIMESTAMP" pattern="yyyy-MM-dd'T'HH:mm:ss.SSSZ" />
</tstamp>
<echo>Current time (ISO): ${TIMESTAMP}</echo>
<echo message="wsimporting ${protocol}://${host-name}:${host-port}/${server}Service/${port}?WSDL; special args are ${wsimport-special-args}"/>
<exec executable="${env.S1AS_HOME}/bin/wsimport">
<arg line="-keep -d ${env.APS_HOME}/build/module/classes ${protocol}://${host-name}:${host-port}/${server}Service/${port}?WSDL"/>
</exec>
</target>
<target name="prepare-client">
<!--basename file="${server}" property="port" suffix="EJB"/-->
<basename file="${server}" property="port"/>
<antcall target="wsdl-import">
<param name="server" value="${server}"/>
<param name="port" value="${port}"/>
</antcall>
<replace file="client/Client.java" value="${http.host}" token="HTTP_HOST"/>
<replace file="client/Client.java" value="${http.port}" token="HTTP_PORT"/>
<antcall target="compile-client"/>
<antcall target="unjar-client-utils"/>
</target>
<target name="unjar-client-utils">
<unjar src="${env.APS_HOME}/lib/reporter.jar" dest="${env.APS_HOME}/build/module/classes"/>
</target>
<target name="internal-run" if="deploy_succeeded">
<basename file="${client-src-name}" property="client" suffix=".java"/>
<dirname file="${client-src-name}" property="client-directory"/>
<basename file="${client-directory}" property="client-pkg-name"/>
<property name="client-class-name" value="${client-pkg-name}/${client}.class"/>
<echo message="Running appclient with ${client-pkg-name}.${client} ${app-client-parameters} ${app-client-extra-parameters}"/>
<exec executable="${env.S1AS_HOME}/bin/appclient" dir="${env.APS_HOME}/build/module/classes">
<arg line="${client-pkg-name}.${client} ${app-client-parameters} ${app-client-extra-parameters}"/>
</exec>
</target>
<target name="internal-report-success" if="undeploy_succeeded">
<antcall target="report-success"/>
</target>
<target name="internal-report-failure" if="undeploy_failed, deploy_failed">
<antcall target="report-failure"/>
</target>