blob: 45e838e88ac8919e386e3c31906ae6e83f70a518 [file] [log] [blame] [edit]
<?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
* minorman - dbws oracle-specific test target
#******************************************************************************/-->
<!-- This ant project includes the following tasks:
- build (default): cleans, compiles, and packages all tests
- clean: cleans up all generated files and dirs
- compile: compiles all test classes
- package: packages tests into eclipselink-dbws-oracle-depend-test.jar
- test: Runs DBWS Oracle-specific tests
-->
<project name="eclipselink.dbws.test.oracle" default="build" basedir=".">
<!-- Test to make certain that build is run from component dir -->
<available file="../${ant.project.name}" type="dir" property="dbws_test_oracle.is.local"/>
<fail unless="dbws_test_oracle.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_oracle.build.location_temp" file="${ant.file.eclipselink.dbws.test.oracle}"/>
<pathconvert targetos="unix" property="dbws_test_oracle.build.location">
<path>
<pathelement location="${dbws_test_oracle.build.location_temp}"/>
</path>
</pathconvert>
<echo message="dbws_test_oracle.build.location = '${dbws_test_oracle.build.location}'"/>
<condition property="dbws_test_oracle.2.base.dir" value="../.." else="..">
<contains string="${dbws_test_oracle.build.location}" substring="dbws/${ant.project.name}"/>
</condition>
<echo message="dbws_test_oracle.2.base.dir = '${dbws_test_oracle.2.base.dir}'"/>
<property name="dbws_test_oracle.2.common.plugins.dir" value="${dbws_test_oracle.2.base.dir}/plugins"/>
<property name="custom.tasks.lib" value="${dbws_test_oracle.build.location}/${dbws_test_oracle.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"/>
<presetdef
name="DeleteDirQuietly"
>
<delete
dir="_tmp_"
quiet="true"
failonerror="false"
/>
</presetdef>
<presetdef
name="DeleteFileQuietly"
>
<delete
file="_tmp_"
quiet="true"
failonerror="false"
/>
</presetdef>
<macrodef
name="verify_build_dir"
>
<attribute name="name"/>
<attribute name="message"/>
<sequential>
<dirname
property="@{name}.actual.dir"
file="${ant.file}"
/>
<pathconvert
targetos="unix"
property="@{name}.actual.dir.unix"
>
<path>
<pathelement
location="${@{name}.actual.dir}"
/>
</path>
</pathconvert>
<dirname
property="@{name}.actual.dir.parent"
file="."
/>
<pathconvert
targetos="unix"
property="@{name}.actual.dir.parent.unix"
>
<path>
<pathelement
location="${@{name}.actual.dir.parent}"
/>
</path>
</pathconvert>
<property
name="@{name}.dir"
value="${@{name}.actual.dir.parent.unix}/@{name}"
/>
<fail
message="@{message}"
>
<condition>
<not>
<equals arg1="${@{name}.actual.dir.unix}" arg2="${@{name}.dir}"/>
</not>
</condition>
</fail>
</sequential>
</macrodef>
<!-- Test to make certain that build is run from component dir -->
<verify_build_dir
name="${ant.project.name}"
message="Not running from '${ant.project.name}' directory"
/>
<property
name="version.qualifier"
value="qualifier"
/>
<!-- user property overrides -->
<property file="${user.home}/build.properties"/>
<!-- properties checked into SVN -->
<property file="${dbws_test_oracle.build.location}/antbuild.properties"/>
<!-- user testing properties overrides -->
<property file="${user.home}/test.properties"/>
<!-- testing properties checked into SVN -->
<property file="${dbws_test_oracle.build.location}/test.properties"/>
<!-- Test dependencies -->
<available file="${junit.lib}" property="junit.jar.exist"/>
<available file="${jdbc.driver.jar}" property="jdbc.jar.exist"/>
<condition property="support.test">
<and>
<isset property="junit.jar.exist"/>
<isset property="jdbc.jar.exist"/>
<isset property="db.platform"/>
<!-- bit too lenient, but means we don't have to change for Oracle12, Oracle13 .. -->
<matches
pattern="org.eclipse.persistence.platform.database.oracle.Oracle[0-9]{1,2}Platform"
string="${db.platform}"
/>
</and>
</condition>
<!--
compile path is complex, not just eclipselink.jar
Put core (plugin) modules first on path so that any
in-progress work that has just be re-compiled will be
picked up ahead of eclipselink.jar
-->
<!-- Set Compile Path-->
<path id="dbws.test.oracle.compile.path">
<pathelement path="${junit.lib}"/>
<fileset
dir="${dbws_test_oracle.2.common.plugins.dir}"
includes="${eclipselink.depend}"
/>
<pathelement path="../../eclipselink.jar"/>
</path>
<!-- Test Path-->
<path id="dbws.test.oracle.test.path">
<pathelement location="${jdbc.driver.jar}"/>
<pathelement path="${junit.lib}"/>
<fileset
dir="${dbws_test_oracle.2.common.plugins.dir}"
includes="${eclipselink.depend}"
/>
<pathelement path="../../eclipselink.jar"/>
<pathelement path="./${eclipselink.dbws.oracle.test.jar}"/>
</path>
<!-- these presets and macros must be defined AFTER .properties read -->
<presetdef name="javac">
<javac
fork="true"
debug="${javac.debug}"
debuglevel="${javac.debuglevel}"
source="${javac.version}"
target="${javac.version}"
failonerror="true"
memoryMaximumSize="512m"
/>
</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}"
delimiter="|"
>
<classpath>
<pathelement location="${jdbc.driver.jar}"/>
</classpath>
<fileset
dir="${etc.dir}"
>
<include name="dbsetup_@{testsuite-name}.sql"/>
</fileset>
</sql>
</sequential>
</macrodef>
<macrodef
name="RunTestsuite"
>
<attribute name="testsuite-name"/>
<attribute name="package-name"/>
<sequential>
<junit
printsummary="withOutAndErr"
fork="yes"
forkmode="once"
maxmemory="512m"
>
<classpath refid="dbws.test.oracle.test.path"/>
<formatter
type="xml"
/>
<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>
</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}"
delimiter="|"
>
<classpath>
<pathelement location="${jdbc.driver.jar}"/>
</classpath>
<fileset
dir="${etc.dir}"
>
<include name="dbteardown_@{testsuite-name}.sql"/>
</fileset>
</sql>
</sequential>
</macrodef>
<macrodef
name="SetupRunTeardown"
>
<attribute name="testsuite-name"/>
<sequential>
<toLower
input="@{testsuite-name}"
property="package-name"
/>
<SetupDatabase
testsuite-name="${package-name}"
/>
<RunTestsuite
testsuite-name="@{testsuite-name}"
package-name="${package-name}"
/>
<TeardownDatabase
testsuite-name="${package-name}"
/>
</sequential>
</macrodef>
<macrodef
name="Report"
>
<sequential>
<junitreport
todir="./${report.dir}"
>
<fileset
dir="."
>
<include
name="TEST-*TestSuite.xml"
/>
</fileset>
<report
format="noframes"
todir="./${report.dir}"
/>
</junitreport>
<delete>
<fileset dir="." includes="TEST-*xml"/>
</delete>
</sequential>
</macrodef>
<!-- Primary Targets: "jar" separate for dev use -->
<target name="build" depends="clean, compile, package" if="support.test"/>
<target name="test" depends="build, run-tests" description="run tests after building"/>
<target
name="clean"
if="support.test"
>
<DeleteDirQuietly dir="${classes.dir}"/>
<mkdir dir="${classes.dir}"/>
<DeleteFileQuietly file="${eclipselink.dbws.oracle.test.jar}"/>
</target>
<target
name="compile"
if="support.test"
>
<javac
srcdir="${src.dir}"
destdir="${classes.dir}"
classpathref="dbws.test.oracle.compile.path"
/>
</target>
<target
name="package"
if="support.test"
>
<jar
jarfile="./${eclipselink.dbws.oracle.test.jar}">
<fileset dir="${classes.dir}">
<include name="dbws/testing/**/*.class"/>
</fileset>
</jar>
</target>
<target
name="run-tests"
if="support.test"
depends="build"
>
<DeleteDirQuietly dir="./${report.dir}"/>
<mkdir dir="./${report.dir}"/>
<SetupRunTeardown testsuite-name="OracleObjecttype"/>
<SetupRunTeardown testsuite-name="PLSQLcollection"/>
<SetupRunTeardown testsuite-name="Veearray"/>
<Report />
</target>
</project>