blob: 4396b3a0cd4b62f3b8e51a2f8e0c57e1c036784e [file] [log] [blame]
<!--
Copyright (c) 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
-->
<!--
For now this is a separate file. Later on it might be merged
with other the common file(appserv-tests/config/common.xml)
-->
<!--
Variable name guidelines
- property names that are exported by the test framework(properties.xml)
should be of the form
build.some-property-name-here
- ant targets defined by the test framework(this file)
should be of the form
common-do-my-job
- properties that are to set by test authors and are dependent per test
(eg set in build.properties) and used in the test framework
should be of the form
my.app-name
compile.source.dir
- properties specified by the test specific build.xml calling into
the common build target of the form
run.testng.classpath
run.testng.classfileset
compile.source.dir
-->
<!--
@todo
- change variable names to follow guidelines above
-->
<!-- ================================================================ -->
<!-- Targets to clean class files and jars files -->
<!--
Variables used:
${build.classes.dir}
${build.assemble.dir}
-->
<!-- ================================================================ -->
<target name="common-clean-classes" depends="init-common">
<echo message="common.xml: Cleaning test source files: ${build.base.dir}"
level="verbose"/>
<delete dir="${build.base.dir}"/>
</target>
<target name="common-clean-jars" depends="init-common">
<delete dir="${build.assemble.dir}"/>
</target>
<target name="common-clean" depends="init-common">
<antcall target="common-clean-classes"/>
<antcall target="common-clean-jars"/>
</target>
<!--
@todo
this target needs to figure out if the ${variable-nae} has been
defined or not and take appropriate action - exit ?
parameters
- ${variable-name}
-->
<target name="verify-variable-defined">
<!--
if ${variable-name} defined
// great
else
// exit/warn - maybe have variants of the verify target to warn/exit
-->
</target>
<!--
Variables used:
@todo change the top 2 variable names
${build.classes.dir}
${build.s1astest.classpath}
${compile.source.dir}
-->
<!-- ================================================================ -->
<target name="common-compile" depends="init-common" >
<mkdir dir="${build.classes.dir}"/>
<echo message="common.xml: Compiling test source files" level="verbose"/>
<mkdir dir="${compile.source.dir}"/>
<javac srcdir="${compile.source.dir}"
destdir="${build.classes.dir}"
classpath="${build.s1astest.classpath}"
debug="on"
failonerror="true"/>
</target>
<target name="test-tlds-exist">
<available file="${tlds}" property="tlds-exist"/>
</target>
<target name="test-tagfiles-exist">
<available file="${tagfiles}" property="tagfiles-exist"/>
</target>
<target name="common-copy-tlds" if="tlds-exist"
depends="common-delete-war-file,test-tlds-exist">
<mkdir dir="${build.classes.dir}/tmp/WEB-INF/tlds"/>
<copy todir="${build.classes.dir}/tmp/WEB-INF/tlds" failonerror="false">
<fileset dir="${tlds}">
<include name="**/*.tld"/>
</fileset>
</copy>
</target>
<target name="common-copy-tagfiles" if="tagfiles-exist"
depends="common-delete-war-file,test-tagfiles-exist">
<mkdir dir="${build.classes.dir}/tmp/WEB-INF/tags"/>
<copy todir="${build.classes.dir}/tmp/WEB-INF/tags" failonerror="false">
<fileset dir="${tagfiles}">
<include name="**/*.tag"/>
<include name="**/*.tagx"/>
</fileset>
</copy>
</target>
<target name="common-delete-war-file">
<delete file="${build.war.file}"/>
</target>
<!-- ================================================================ -->
<!--
Variables Used:
@todo change variable names to be more meaningful names
${build.classes.dir}
${build.assemble.dir}
${my-app-name}
${web.xml}
...
-->
<!-- ================================================================ -->
<target name="common-build-war" if="hasWebclient" depends="init-common">
<mkdir dir="${build.assemble.dir}"/>
<antcall target="common-package-war">
<param name="build.war.classes" value="${build.classes.dir}"/>
<param name="build.war.file" value="${build.assemble.dir}/${my-app-name}-web.war"/>
</antcall>
</target>
<target name="common-package-war"
depends="common-copy-tlds, common-copy-tagfiles">
<echo message="my build classes dir is:${build.classes.dir}" level="verbose"/>
<mkdir dir="${build.classes.dir}/tmp"/>
<mkdir dir="${build.classes.dir}/tmp/WEB-INF"/>
<mkdir dir="${build.classes.dir}/tmp/WEB-INF/classes"/>
<mkdir dir="${build.classes.dir}/tmp/WEB-INF/lib"/>
<mkdir dir="lib"/>
<copy file="${sun-web.xml}"
tofile="${build.classes.dir}/tmp/WEB-INF/sun-web.xml" failonerror="false"/>
<copy todir="${build.classes.dir}/tmp/WEB-INF/lib" failonerror="false">
<fileset dir="lib">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
</copy>
<copy file="${webservices.xml}"
tofile="${build.classes.dir}/tmp/WEB-INF/webservices.xml"
failonerror="false"/>
<copy file="${mappingfile.location}/${mappingfile.name}"
tofile="${build.classes.dir}/tmp/${mappingfile.name}"
failonerror="false"/>
<copy file="${wsdlfile.location}/${wsdlfile.name}"
tofile="${build.classes.dir}/tmp/WEB-INF/wsdl/${wsdlfile.name}"
failonerror="false"/>
<copy file="${tagPlugins.xml}"
tofile="${build.classes.dir}/tmp/WEB-INF/tagPlugins.xml"
failonerror="false"/>
<copy file="${web.xml}"
tofile="${build.classes.dir}/tmp/WEB-INF/web.xml"/>
<copy todir="${build.classes.dir}/tmp/WEB-INF/classes">
<fileset dir="${build.war.classes}">
<include name="**/*.class"/>
</fileset>
</copy>
<echo message="Creating war file ${build.war.file}" level="verbose"/>
<mkdir dir="${basedir}/docroot"/>
<jar jarfile="${build.war.file}" update="true">
<fileset dir="${build.classes.dir}/tmp" casesensitive="yes">
<include name="**/*class*"/>
</fileset>
<fileset dir="${basedir}/docroot" casesensitive="yes">
<include name="**/*.html"/>
<include name="**/*.jsp"/>
<include name="**/*.jspx"/>
<include name="**/*.jspf"/>
<include name="**/*.gif"/>
<include name="**/*.do"/>
<include name="**/*.txt"/>
<exclude name="**/*.java,**/*.xml,**/*.properties"/>
</fileset>
<fileset dir="${build.classes.dir}/tmp/" casesensitive="true">
<include name="WEB-INF/web.xml"/>
<include name="WEB-INF/sun-web.xml"/>
<include name="WEB-INF/webservices.xml"/>
<include name="WEB-INF/tagPlugins.xml"/>
<include name="WEB-INF/lib/*"/>
<include name="WEB-INF/lib/extra/*"/>
<include name="WEB-INF/tlds/*"/>
<include name="WEB-INF/tags/*"/>
<include name="WEB-INF/wsdl/${wsdlfile.name}"/>
<include name="${mappingfile.name}"/>
</fileset>
</jar>
<echo message="created war file ${build.war.file}" level="verbose"/>
<delete dir="${build.classes.dir}/tmp/WEB-INF" failonerror="false"/>
</target>
<target name="common-deploy-war">
<antcall target ="common-pe-deploy-war"/>
<antcall target ="common-ee-deploy-war"/>
</target>
<target name="common-pe-deploy-war" depends="init-common" unless="ee">
<echo message="Deploying ${build.assemble.dir}/${my-app-name}-web.war from ${basedir}."
level="verbose"/>
<property name="precompilejsp" value="true"/>
<exec executable="${ASADMIN}" failonerror="false">
<arg line="deploy"/>
<arg line="${as.props}"/>
<arg line="--contextroot ${my-contextroot}"/>
<arg line="--precompilejsp=${precompilejsp}"/>
<arg line="--upload=true"/>
<arg line="--target ${appserver.instance.name}"/>
<arg line="${build.assemble.dir}/${my-app-name}-web.war"/>
</exec>
</target>
<target name="common-ee-deploy-war" if="ee">
<property name="precompilejsp" value="true"/>
<exec executable="${ASADMIN}" failonerror="false">
<arg line="deploy"/>
<arg line="${as.props}"/>
<arg line="--type web"/>
<arg line="--contextroot ${my-contextroot}"/>
<arg line="--precompilejsp=${precompilejsp}"/>
<arg line="--upload=true"/>
<arg line="--target ${appserver.instance.name}"/>
<arg line="${build.assemble.dir}/${my-app-name}-web.war"/>
</exec>
</target>
<!-- undeploy the standalone war in AppServ -->
<target name="common-undeploy-war" depends="init-common">
<echo message="Undeploying warfile ${my-app-name}-web from
${build.assemble.dir}/${my-app-name}-web.war from ${basedir}."
level="verbose"/>
<exec executable="${ASADMIN}" failonerror="false">
<arg line="undeploy"/>
<arg line="${as.props}"/>
<arg line="--target ${appserver.instance.name}"/>
<arg line="${my-app-name}-web"/>
</exec>
</target>
<!-- Path to the TestNG library -->
<path id="path2testng">
<pathelement location="${env.APS_HOME}/lib/testng.jar"/>
</path>
<!-- TestNG ant task definition -->
<taskdef name="testng"
classpathref="path2testng"
classname="org.testng.TestNGAntTask"/>
<!-- common task for compilation of TestNG tests -->
<!-- Variables needed
${compile.testng.srcdir}
${compile.testng.destdir}
${compile.testng.classpath}
-->
<target name="common-compile-testng-tests"
description="compile testng tests" depends="">
<delete dir="${compile.testng.destdir}"/>
<mkdir dir="${compile.testng.destdir}"/>
<javac debug="true"
fork="true"
source="1.5"
srcdir="${compile.testng.srcdir}"
destdir="${compile.testng.destdir}"
classpathref="${compile.testng.classpath}"
/>
</target>
<!-- Generate the TestNG report - uses junit -->
<!-- TestNG generates detailed reports in the output
directory(default test-output) but junit does a nice compilation
of all the test results -->
<target name="common-report">
<delete dir="test-report"/>
<mkdir dir="test-report"/>
<echo message="Running report from common-build.xml ..."/>
<junitreport todir="test-report">
<fileset dir=".">
<include name="**/test-output/**/*.xml"/>
<exclude name="**/testng-fail*.xml"/>
</fileset>
<report format="noframes" todir="test-report"/>
</junitreport>
</target>
<!--
The common target to run-groups. The following variables need
to be defined by caller:
${run.testng.xmlfileset}
${run.testng.classpath}
${run.testng.xmlfileset} should be a fileset refid
${run.testng.classpath} should be a path refid
-->
<target name="common-run">
<echo message="base dir: ${basedir}"/>
<delete dir="test-output"/>
<testng outputdir="test-output"
classpathref="${run.testng.classpath}"
xmlfilesetref="${run.testng.xmlfileset}">
</testng>
</target>
<!-- The common target to run failed tests from the last run only.
Because of the way testng works(never overwrites testng-failed.xml
from previous runs and this keep accumulating causing ...)
common-run-failed moves that testng-failed.xml and moves it to
test-tmp directory. It then runs tests on test-tmp/testng-failed.xml
-->
<target name="common-run-failed">
<delete dir="test-tmp/"/>
<move todir="test-tmp/">
<fileset dir="." includes="**/test-output/**/testng-failed.xml"/>
</move>
<delete dir="test-output/"/>
<testng outputdir="test-output"
classpathref="${run.testng.classpath}">
<!-- <classpath location="${build.dir}"/> -->
<xmlfileset dir="."
includes="test-tmp/**/testng-failed.xml">
</xmlfileset>
</testng>
</target>
<!--
The common target to run-groups. The following variables need
to be defined by caller:
${run.testng.classfileset}
${run.testng.classpath}
${run.testng.classfileset} should be a fileset refid
${run.testng.classpath} should be a path refid
${group-names} needs to be specified as well -
usually this should be done
by the caller that invokes ant
Note: can't seem to run using testng with the groups option
and testng.xml files as in with xmlfilesetref or xmlfileset
-->
<target name="common-run-groups">
<delete dir="test-output"/>
<echo message="value of run.testng.classpath ${run.testng.classpath}"/>
<echo message="value of run.testng.classfileset ${run.testng.classfileset}"/>
<testng outputdir="test-output"
groups="${group-names}"
classfilesetref="${run.testng.classfileset}"
classpathref="${run.testng.classpath}">
</testng>
</target>
<!--WorkInProgress - compile and build the common util into a jar file library -->
<target name="compile-build-util">
<delete dir="${env.APS_HOME}/build/util"/>
<mkdir dir="${env.APS_HOME}/build/util"/>
<javac srcdir="${env.APS_HOME}/devtestsNG/common/src"
destdir="${env.APS_HOME}/build/util"
classpath="${env.S1AS_HOME}/lib/javaee.jar:${env.S1AS_HOME}/lib/appserv-ext.jar">
</javac>
<delete file="${env.APS_HOME}/lib/myutil.jar"/>
<jar destfile="${env.APS_HOME}/lib/myutil.jar"
basedir="${env.APS_HOME}/build/util"/>
</target>