| <?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 '.' |
| * - multi-word targets use hyphens '-' |
| * - multi-word macros use underscores '_' |
| * - multi-word macro attributes are concatinated |
| * e.g. 'runpathref' |
| * - multi-word tasks (taskdef) names are concatinated |
| * 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" file="${ant.file.org.eclipse.persistence.core}"/> |
| <condition property="dbws_test.2.common.plugins.dir" value="../../plugins" else="../plugins"> |
| <contains string="${dbws_test.build.location}" substring="dbws"/> |
| </condition> |
| |
| <!-- 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="./build.properties"/> |
| <!-- local testing properties overrides --> |
| <property file="${user.home}/test.properties"/> |
| <!-- testing properties checked into SVN --> |
| <property file="./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.name}"/> |
| <pathelement path="${dbws_test.2.common.plugins.dir}/${asm}"/> |
| <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.utils.dbws.common.jar.name}"/> |
| </path> |
| <!-- Test dependencies --> |
| <available file="../../${eclipselink.jar.name}" property="eclipselink.jar.exist"/> |
| <available file="${dbws_test.2.common.plugins.dir}/${asm}" type="dir" property="asm.exist"/> |
| <available file="${jdbc.driver.jar}" property="jdbc.jar.exist"/> |
| <available file="./${eclipselink.dbws.test.common.jar.name}" 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> |
| |
| <!-- all --> |
| <target name="build" depends="clean, compile, package" description="build dbwsutils jar"/> |
| |
| <!-- test --> |
| <target name="test" depends="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> |
| <scriptdef |
| name="toLower" |
| language="javascript" |
| manager="javax" |
| > |
| <attribute name="input"/> |
| <attribute name="property"/> |
| <![CDATA[ |
| // getting the value |
| input = attributes.get("input"); |
| property = attributes.get("property"); |
| if (input == null || property == null) { |
| self.fail("both 'input' and 'property' attributes must be set."); |
| } |
| lowercaseInput = input.toLowerCase(); |
| // put result into property - NB overwrites previous value! Not safe for <parallel> tasks |
| project.setProperty(attributes.get("property"), lowercaseInput); |
| ]]> |
| </scriptdef> |
| |
| <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="SetupCompileRunTeardown" |
| > |
| <attribute name="testsuite-name"/> |
| <sequential> |
| <toLower |
| input="@{testsuite-name}" |
| property="package-name" |
| /> |
| <SetupDatabase |
| testsuite-name="${package-name}" |
| /> |
| <CompileTestsuite |
| testsuite-name="@{testsuite-name}" |
| package-name="${package-name}" |
| /> |
| <RunTestsuite |
| testsuite-name="@{testsuite-name}" |
| package-name="${package-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.name}"/> |
| </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..."/> |
| <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.name}"> |
| <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.name}" 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"/> |
| </target> |
| </project> |