blob: e52782577fb71e60ca4a91eabb198abe51a95879 [file] [log] [blame]
<?xml version="1.0"?>
<!--/*******************************************************************************
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Ant naming conventions:
* - regardless of the actual OS platform,'/' is the directory separator
* (Ant will convert as appropriate).
* - multi-word properties use periods '.'
* - properties ending in .jar define jarfile names only (no path)
* - properties ending in .lib are fully qualified jars (path and filename)
* - properties ending in .dir are directory paths
* - properties ending in .path are path refid names (classpath fragments)
* - multi-word targets use hyphens '-'
* - targets beginning with test- are reserved for high level test targets,
* and are used in test results parsing
* - targets typically use the form <action>-<object>-<type> (ie. package-bundle-zip)
* - multi-word macros use underscores '_'
* - multi-word macro attributes are concatenated
* e.g. 'runpathref'
* - multi-word tasks (taskdef) names are concatenated
* e.g. 'validateconnection'
* - OS environment variables are in ALLCAPS and have 'env' as a prefix
* e.g. ${env.XXX}.
* - Ant properties are lower case.
*
* Contributors:
* egwin - initial API and implementation
#******************************************************************************/-->
<project name="eclipselink.dbws.test" default="build" basedir=".">
<!-- Test to make certain that build is run from component dir -->
<available file="../${ant.project.name}" type="dir" property="dbws_test.is.local"/>
<fail unless="dbws_test.is.local" message="Not running from '${ant.project.name}' directory"/>
<condition property="is.java.version.16">
<equals arg1="${ant.java.version}" arg2="1.6"/>
</condition>
<!-- Sets the warning message appropriately -->
<condition property="jdk_message" value="Warning: Minimum of JDK6 is required for this component to build." else="java.version='${java.version}'">
<contains string="${java.version}" substring="1.5"/>
</condition>
<echo message="${jdk_message}"/>
<!-- Setup relative pathing for build -->
<dirname property="dbws_test.build.location_temp" file="${ant.file.eclipselink.dbws.test}"/>
<pathconvert targetos="unix" property="dbws_test.build.location">
<path>
<pathelement location="${dbws_test.build.location_temp}"/>
</path>
</pathconvert>
<echo message="dbws_test.build.location = '${dbws_test.build.location}'"/>
<condition property="dbws_test.2.base.dir" value="../.." else="..">
<contains string="${dbws_test.build.location}" substring="dbws/${ant.project.name}"/>
</condition>
<echo message="dbws_test.2.base.dir = '${dbws_test.2.base.dir}'"/>
<property name="dbws_test.2.common.plugins.dir" value="${dbws_test.2.base.dir}/plugins"/>
<property name="custom.tasks.lib" value="${dbws_test.build.location}/${dbws_test.2.base.dir}/buildsystem/ant_customizations.jar"/>
<property name="custom.tolower.task.class" value="org.eclipse.persistence.buildtools.ant.taskdefs.ToLower"/>
<available file="${custom.tasks.lib}" property="ant_customizations.exist"/>
<fail unless="ant_customizations.exist" message="Cannot find custom tasks library: '${custom.tasks.lib}' directory"/>
<taskdef name="toLower" classname="${custom.tolower.task.class}" classpath="${custom.tasks.lib}"/>
<!-- OS environment variables have 'env' as a prefix -->
<property environment="env"/>
<!-- local property overrides -->
<property file="${user.home}/build.properties"/>
<!-- properties checked into SVN -->
<property file="${dbws_test.build.location}/antbuild.properties"/>
<!-- local testing properties overrides -->
<property file="${user.home}/test.properties"/>
<!-- testing properties checked into SVN -->
<property file="${dbws_test.build.location}/test.properties"/>
<!-- versioning -->
<!-- These variables are set in autobuild.xml. A manual build gets defaults -->
<tstamp>
<format property="build.date" pattern="yyyyMMdd"/>
<format property="build.time" pattern="HHmm"/>
</tstamp>
<property name="build.type" value="SNAPSHOT"/>
<property name="svn.revision" value="NA"/>
<property name="version.string" value="${release.version}.qualifier"/>
<property name="release.designation" value="EclipseLink DeveloperBuild"/>
<!-- Set Compile Path-->
<path id="dbws_test.compile.path">
<pathelement path="${junit.lib}"/>
<pathelement path="../../${eclipselink.jar}"/>
<pathelement path="${dbws_test.2.common.plugins.dir}/${asm}"/>
<pathelement path="${dbws_test.2.common.plugins.dir}/${persistence.jar}"/>
<fileset
dir="${dbws_test.2.common.plugins.dir}"
includes="${eclipselink.dbws.depend}"
/>
</path>
<!-- Set Run Path-->
<path id="dbws_test.run.path">
<path refid="dbws_test.compile.path"/>
<pathelement path="${jdbc.driver.jar}"/>
<pathelement path="./${eclipselink.dbws.test.common.jar}"/>
</path>
<!-- Test dependencies -->
<available file="../../${eclipselink.jar}" property="eclipselink.jar.exist"/>
<available file="${dbws_test.2.common.plugins.dir}/${asm}" type="dir" property="asm.exist"/>
<available file="${dbws_test.2.common.plugins.dir}/${persistence.jar}" property="persistence.jar.exist"/>
<available file="${jdbc.driver.jar}" property="jdbc.jar.exist"/>
<available file="./${eclipselink.dbws.test.common.jar}" property="dbws_test.common.jar.exist"/>
<condition property="support.test">
<and>
<isset property="is.java.version.16"/>
<isset property="jdbc.jar.exist"/>
<isset property="db.platform"/>
<matches
pattern="org.eclipse.persistence.platform.database.MySQLPlatform"
string="${db.platform}"
/>
</and>
</condition>
<!-- Primary Targets: "jar" separate for dev use -->
<target name="build" depends="clean, compile, package" description="build dbws test jar"/>
<target name="test" depends="build, compile-common, run-tests" description="run tests after building"/>
<!-- MACRO and SCRIPT definitions -->
<presetdef name="javac">
<javac
debug="${javac.debug}"
debuglevel="${javac.debuglevel}"
optimize="${javac.optimize}"
source="1.6"
target="1.6"
deprecation="${javac.deprecation}"
failonerror="true"
memoryMaximumSize="512m"
/>
</presetdef>
<presetdef
name="DeleteDirQuietly"
>
<delete
dir="_tmp_"
quiet="true"
failonerror="false"
/>
</presetdef>
<presetdef
name="DeleteFileQuietly"
>
<delete
file="_tmp_"
quiet="true"
failonerror="false"
/>
</presetdef>
<macrodef
name="SetupDatabase"
>
<attribute name="testsuite-name"/>
<sequential>
<sql
onerror="continue"
keepformat="true"
driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pwd}"
classpathref="dbws_test.run.path"
delimiter="|"
>
<fileset
dir="./${etc.dir}"
>
<include name="dbsetup_@{testsuite-name}.sql"/>
</fileset>
</sql>
</sequential>
</macrodef>
<macrodef
name="CompileTestsuite"
>
<attribute name="testsuite-name"/>
<attribute name="package-name"/>
<sequential>
<mkdir
dir="./${classes.dir}"
/>
<javac
fork="true"
srcdir="./${src.dir}"
destdir="./${classes.dir}"
includes="dbws/testing/@{package-name}/*.java"
classpathref="dbws_test.run.path"
/>
</sequential>
</macrodef>
<macrodef
name="RunTestsuite"
>
<attribute name="testsuite-name"/>
<attribute name="package-name"/>
<sequential>
<junit
printsummary="withOutAndErr"
fork="yes"
forkmode="once"
maxmemory="512m"
>
<formatter
type="xml"
/>
<classpath>
<path
refid="dbws_test.run.path"
/>
<pathelement
path="./${classes.dir}"
/>
</classpath>
<sysproperty
key="eclipselink.logging.level"
value="${logging.level}"
/>
<sysproperty
key="db.driver"
value="${db.driver}"
/>
<sysproperty
key="db.url"
value="${db.url}"
/>
<sysproperty
key="db.user"
value="${db.user}"
/>
<sysproperty
key="db.pwd"
value="${db.pwd}"
/>
<sysproperty
key="db.platform"
value="${db.platform}"
/>
<test
name="dbws.testing.@{package-name}.@{testsuite-name}TestSuite"
/>
</junit>
<junitreport
todir="./${report.dir}"
>
<fileset
dir="."
>
<include
name="TEST-*TestSuite.xml"
/>
</fileset>
<report
format="noframes"
todir="./${report.dir}"
/>
</junitreport>
</sequential>
</macrodef>
<macrodef
name="TeardownDatabase"
>
<attribute name="testsuite-name"/>
<sequential>
<sql
onerror="continue"
keepformat="true"
driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pwd}"
classpathref="dbws_test.run.path"
delimiter="|"
>
<fileset
dir="./${etc.dir}"
>
<include name="dbteardown_@{testsuite-name}.sql"/>
</fileset>
</sql>
</sequential>
</macrodef>
<macrodef
name="CompileRun"
>
<attribute name="testsuite-name"/>
<sequential>
<toLower
input="@{testsuite-name}"
property="package-name"
/>
<CompileTestsuite
testsuite-name="@{testsuite-name}"
package-name="${package-name}"
/>
<RunTestsuite
testsuite-name="@{testsuite-name}"
package-name="${package-name}"
/>
</sequential>
</macrodef>
<macrodef
name="SetupCompileRunTeardown"
>
<attribute name="testsuite-name"/>
<sequential>
<toLower
input="@{testsuite-name}"
property="package-name"
/>
<SetupDatabase
testsuite-name="${package-name}"
/>
<CompileRun
testsuite-name="@{testsuite-name}"
/>
<TeardownDatabase
testsuite-name="${package-name}"
/>
</sequential>
</macrodef>
<!-- clean -->
<target name="clean" description="Clean generated files for common content">
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${classes.dir}"/>
<fileset dir="." includes="${dbws_util.jar}"/>
</delete>
</target>
<!-- compile -->
<target name="compile" description="Compile DBWS Util test Common classes">
<fail unless="eclipselink.jar.exist" message="EclipseLink cannot be found. Exiting..."/>
<fail unless="asm.exist" message="ASM Bundle cannot be found. Exiting..."/>
<fail unless="persistence.jar.exist" message="Persistence JAR cannot be found. Exiting..."/>
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
includes="dbws/testing/*.java"
fork="true"
classpathref="dbws_test.compile.path"
/>
</target>
<!-- package -->
<target name="package" description="package DBWS Util Test Common jar">
<jar jarfile="./${eclipselink.dbws.test.common.jar}">
<fileset dir="${classes.dir}">
<include name="dbws/testing/*.class"/>
</fileset>
</jar>
</target>
<!-- *** Test execution targets *** -->
<target name="compile-common" unless="dbws_test.common.jar.exist">
<antcall target="build" inheritAll="true" inheritRefs="true"/>
<available file="./${eclipselink.dbws.test.common.jar}" property="dbws_test.common.jar.exist"/>
</target>
<target name="run-tests" if="support.test" description="setup, compile, and run dbws util testsuites">
<DeleteDirQuietly dir="./${report.dir}"/>
<mkdir dir="./${report.dir}"/>
<SetupCompileRunTeardown testsuite-name="KeyMappings"/>
<SetupCompileRunTeardown testsuite-name="Relationships"/>
<CompileRun testsuite-name="XRDynamicEntity"/>
</target>
</project>