Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

444 lines (388 sloc) 19.87 kb
<?xml version="1.0" encoding="UTF-8"?>
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
This ANT build file is used to run the JPA 2.0 TCK. It assumes that you have
the TCK, config and patches zip files located at:
${user.home}/.m2/privaterepos/ (may not exist)
If you have that file in a different location, it can be specified with
the "" and "" system property.
The TCK running process will do the following:
1. Find the TCK zip file and extract it
2. Create an file with the OpenJPA config
3. Modify the TCK's main configuration file (ts.jte) to use OpenJPA
4. Run the database initialization script
5. Run the TCK script
6. Parse the TCK result log to determine to fail the build or not
Other options are documented in the Maven pom.xml which calls this script.
Please keep the project tag on one line to avoid confusing
the release plugin.
<project name="JPA2TCK" default="run-tck">
<!-- Import antlib/ant-contrib for If/then/else/for support -->
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
Target: init
Description: This initializes required properties and validates that
required TCK zip files are present on the system and
then extracts them.
<target name="init">
<property name="tck.level" value="jpatck-2.0_15-Aug-2011" />
<property name="" value="${LOCAL_M2_REPO}/../privaterepos/${tck.level}.zip" />
<available property="tck.available" file="${}" />
<fail unless="tck.available">The TCK file specified in the "" system property (${}) does not exist. This file must be downloaded separately in order to be able to run the JPA 2.0 TCK</fail>
<property name="" value="${LOCAL_M2_REPO}/../privaterepos/${tck.level}" />
<available property="tck_config.available" file="${}" />
<fail unless="tck_config.available">The TCK config file specified in the "" system property (${}) does not exist. This file must be downloaded separately in order to be able to run the JPA 2.0 TCK</fail>
<property name="" value="${LOCAL_M2_REPO}/../privaterepos/${tck.level}" />
<available property="tck_patches.available" file="${}" />
<fail unless="tck_patches.available">The TCK patches file specified in the "" system property (${}) does not exist. This file must be downloaded separately in order to be able to run the JPA 2.0 TCK</fail>
<delete dir="${tck.dir}" />
<unzip overwrite="false" src="${}" dest="${tck.base}" />
<unzip overwrite="true" src="${}" dest="${tck.base}" />
<unzip overwrite="true" src="${}" dest="${tck.base}" />
<copy overwrite="true"
file="${tck.dir}/bin/ts.jte" tofile="${tck.dir}/bin/ts.jte.orig" />
<copy overwrite="true"
file="${tck.dir}/bin/ts.jtx" tofile="${tck.dir}/bin/ts.jtx.orig" />
<!-- Pluggability tests using Toplink needs this dir created -->
<mkdir dir="${tck.dir}/domains/domain1/logs" />
<!-- create other missing directory -->
<mkdir dir="${tck.dir}/weblib" />
Target: setup
Description: This updates the TCK configuration for OpenJPA.
<target name="setup">
<property name="" value="${}" />
<property name="db.driver" value="${}" />
<property name="db.url" value="${connection.url}" />
<property name="db.username" value="${connection.username}" />
<property name="db.password" value="${connection.password}" />
<property name="openjpa.Log" value="DefaultLevel=TRACE" />
<property name="jpatck.test" value="" />
<property name="tck.reports" value="${tck.base}/reports" />
<property name="" value="${tck.base}/work" />
<property name="" value="${tck.dir}/" />
<property name="" value="${tck.dir}/bin/" />
<!-- create the OpenJPA properties for the TCK run -->
<echo append="false" file="${}">
javax.persistence.provider: org.apache.openjpa.persistence.PersistenceProviderImpl
openjpa.ConnectionDriverName: ${db.driver}
openjpa.ConnectionURL: ${db.url}
openjpa.ConnectionUserName: ${db.username}
openjpa.ConnectionPassword: ${db.password}
openjpa.FetchBatchSize: -1
openjpa.Compatibility: StrictIdentityValues=true
openjpa.Sequence: time
openjpa.Log: ${openjpa.Log}
openjpa.jdbc.DBDictionary: (StoreCharsAsNumbers=true,NumericTypeName="DECIMAL(18,2)")
openjpa.jdbc.SchemaFactory: native(ForeignKeys=true)
openjpa.jdbc.SynchronizeMappings: buildSchema(ForeignKeys=true)
openjpa.ConnectionFactoryProperties: PrintParameters=True
<path id="javart">
<fileset dir="${java.home}/lib">
<include name="**/*.jar" />
<pathconvert property="" refid="javart" />
<!-- Append OpenJPA-specific configuration -->
<property name="jpatck.config" value="${tck.dir}/bin/ts.jte" />
<echo append="false" file="${jpatck.config}.tmp">
## OpenJPA specific properties follow
# jpa.classes includes Derby, so only set database.classes for other DBs
# different properties needed for pluggability bucket${}${}
# Need to specify java.* classes, both in Windows/UNIX locations as well as Mac.
# This includes a few different possible locations; only one of them needs to
# actually work for a given environment.
javax.persistence.jdbc.driver: ${db.driver}
javax.persistence.jdbc.url: ${db.url}
javax.persistence.jdbc.user: ${db.username}
javax.persistence.jdbc.password: ${db.password}
# disable initdb.xml table creation
<!-- convert backslashes and known paths with spaces
to get around a problem with the TCK testrunner
on windows -->
<echo>Update directory paths if running on Windows</echo>
<replace summary="yes" file="${jpatck.config}.tmp" replacefilterfile="" />
<!-- append our updated config properties to a clean ts.jte -->
<copy overwrite="true"
file="${tck.dir}/bin/ts.jte.orig" tofile="${tck.dir}/bin/ts.jte" />
<concat append="true" destfile="${jpatck.config}">
<fileset file="${jpatck.config}.tmp" />
<path id="agent.path">
<fileset dir="../../openjpa/target">
<include name="*.jar" />
<exclude name="*-sources.jar" />
<exclude name="*-shaded.jar" />
<exclude name="original-*.jar" />
<exclude name="*-tests.jar" />
<exclude name="*-javadoc.jar" />
<pathconvert dirsep="/" property="agent" refid="agent.path" />
<property name="" value="" />
<echo>AGENT: ${agent}${}</echo>
<!-- Use the following values to start Eclipse remote debug
<property name="DEBUG" value="-Djava.compiler=NONE -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7777" />
<property name="DEBUG" value="" />
Add in a javaagent argument (optional in JPA2 TCK.)
Also, we need to specify the default MetaDataFactory
inorder to allow tests that don't have any
persistent classes to work (like the SignatureTest)
<replace file="${jpatck.config}">
<replacefilter token="-Ddeliverable.class=${deliverable.class}" value="-Ddeliverable.class=${deliverable.class} -javaagent:${agent}${} ${DEBUG} -Dopenjpa.MetaDataFactory=jpa(DefaultAccessType=PROPERTY)"/>
<!-- Fix path for -->
<replace file="${jpatck.config}">
<replacefilter token="${bin.dir}/harness.policy" value="${ts.home}/bin/harness.policy"/>
<!-- cleanup reports/work dirs from any prior runs -->
<delete dir="${tck.reports}" />
<delete dir="${}" />
<echo>Logging JPA 2.0 TCK output to ${tck.log}</echo>
Macro for the TCK harness launcher
<macrodef name="tsant">
<attribute name="dir" default="${tck.dir}/src" />
<attribute name="buildfile" />
<attribute name="target" />
<attribute name="tmo" default="7200000" />
<java classname="" fork="true" failonerror="false" dir="@{dir}" append="true" output="${tck.log}" timeout="@{tmo}" resultproperty="tsant.result">
<arg value="-emacs" />
<arg value="-buildfile" />
<arg value="@{buildfile}" />
<arg value="-listener" />
<arg value="com.sun.ant.TSBuildListener" />
<arg value="-logger" />
<arg value="com.sun.ant.TSLogger" />
<arg value="@{target}" />
<env key="TS_HOME" value="${tck.dir}" />
<sysproperty key="ts.home" value="${tck.dir}" />
<env key="ANT_HOME" value="${tck.dir}/tools/ant" />
<sysproperty key="ant.home" value="${tck.dir}/tools/ant" />
<sysproperty key="pkg.dir" value="${jpatck.pkg.dir}" />
<sysproperty key="test" value="${jpatck.test}" />
<path refid="cp" />
<fileset dir="${tck.dir}/tools/ant/lib">
<include name="**/*.jar" />
<fileset dir="${tck.dir}/lib">
<include name="**/*.jar" />
Macro to determine how many tests passed/failed
<macrodef name="results.count">
<!-- Figure out the Passed/Failed counts -->
<resourcecount property="count.passed">
<containsstring contains="Passed."/>
<fileset dir="${tck.reports}" includes="summary.txt" />
<resourcecount property="count.failed">
<containsstring contains="Failed."/>
<fileset dir="${tck.reports}" includes="summary.txt" />
<echo>TCK Results - Passed: ${count.passed}, Failed: ${count.failed}</echo>
Target: run-tck
Description: This is the main routine that runs the TCK, after
all other setup steps have been performed.
Input: jpatck.pkg.dir System property defines a commna-spearated list of test cases to be run.
If not set or set to empty string, all tck tests will be exercised.
Note: Beaware if jpatck.pkg.dir includes pluggability test in the dir hierarchy, the pluggability
test will fail (5 failures) due to [enable|disable].ts.persistence.provider targets are
not invoked, which is required for the pluggability tests.
<target name="run-tck">
<echo>Running JPA 2.0 TCK tests</echo>
<echo>Init must have been called before running this target!</echo>
<property name="tck.log" value="${tck.base}/openjpa-tck.log" />
<property name="" value="${}" />
<!-- call TCK setup with above run specific properties set -->
<fail unless="OPENJPA_CLASSPATH">The OPENJPA_CLASSPATH was not provided and needs to point to the required OpenJPA and Derby runtime jars.</fail>
<antcall target="setup">
<param name="" value="${OPENJPA_CLASSPATH}" />
<!-- backup our updated ts.jte for later debugging -->
<copy overwrite="true"
file="${tck.dir}/bin/ts.jte" tofile="${tck.base}/ts.jte.tck" />
<!-- HACK - rebuild jpatck/dist jars for persistence.xml fixes -->
<echo>Calling TCK build.all</echo>
<tsant buildfile="${tck.dir}/bin/build.xml" target="build.all" />
<echo>TCK build.all returned result=${tsant.result}</echo>
<!-- first initialize the database -->
<echo>Calling TCK initdb.xml</echo>
<tsant dir="${tck.dir}/bin" buildfile="${tck.dir}/bin/initdb.xml" target="init.database" />
<echo>TCK initdb.xml returned result=${tsant.result}</echo>
<!-- Database table set up -->
<!-- OpenJPA relies on SynchronizeMappings to create the database tables...
... except in a couple of cases where we will pre-create the tables. -->
<echo>Calling OpenJPA create.openjpa.sql.xml</echo>
<ant antfile="${basedir}/sql/create.openjpa.sql.xml" inheritRefs="true" />
<!-- We are attempting to change TCK build.xml;s incorrect property name
for the pluggability test enablement... -->
<replace file="${tck.dir}/bin/build.xml">
<replacefilter token=""
<replace file="${tck.dir}/bin/build.xml">
<replacetoken><![CDATA[<replaceregexp file="${bin.dir}/ts.jte"]]></replacetoken>
<replacevalue><![CDATA[<replaceregexp flags="g" file="${bin.dir}/ts.jte"]]></replacevalue>
<property name="" value="7200000" />
<!-- now run the TCK -->
<isset property="jpatck.pkg.dir" />
<length string="${jpatck.pkg.dir}" trim="true" length="0" />
<for list="${jpatck.pkg.dir}" param="for.test" trim="true">
<contains string="@{for.test}" substring="pluggability"/>
<echo>Calling enable.ts.persistence.provider for pluggability test.</echo>
<tsant buildfile="${tck.dir}/bin/build.xml" target="enable.ts.persistence.provider" />
<echo>Calling TCK build.xml for pkg.dir=@{for.test}</echo>
<property name="dir" value="${tck.dir}/src/@{for.test}" />
<tsant dir="${dir}" buildfile="${dir}/build.xml" target="runclient" tmo="${}" />
<contains string="@{for.test}" substring="pluggability"/>
<echo>Calling disable.ts.persistence.provider for pluggability test.</echo>
<tsant buildfile="${tck.dir}/bin/build.xml" target="disable.ts.persistence.provider" />
<echo>Calling TCK build.xml for ALL tests</echo>
<property name="dir.all" value="${tck.dir}/bin" />
<tsant dir="${dir.all}" buildfile="${dir.all}/build.xml" target="run.all" tmo="${}"/>
<echo>TCK build.xml returned result=${tsant.result}</echo>
<!-- archive the results and check for test failures -->
<antcall target="zip-artifacts">
<param name="" value="tck" />
Target: zip-artifacts
Description: Collects generic TCK test artifacts for debugging
<target name="zip-artifacts">
<echo>Gathering test artifacts for Sun JPA 2.0 TCK</echo>
<copy overwrite="true"
tofile="${tck.base}/summary-${}.txt" />
<property name="tck.results.archive" value="${tck.base}/openjpa-${}" />
<!-- archive the results -->
<zip destfile="${tck.results.archive}">
<fileset dir="${}" />
<fileset dir="${tck.reports}" />
<fileset dir="${tck.base}">
<include name="*${}.log" />
<include name="*${}.txt" />
<include name="ts.jte.${}" />
<echo>Results archive at: ${tck.results.archive}</echo>
The TCK's Java process doesn't actually fail when
tests fail, so we need to parse the results file
for a string indicating whether or not it passed.
<results.count />
<loadfile property="jpatck.results" srcfile="${}/jtData/log.txt" />
<condition property="jpatck.failed">
<contains string="${jpatck.results}" substring="Completed test run: not ok" />
<fail if="jpatck.failed">Test Results (${}): FAILED ${count.failed} tests!</fail>
<!-- else -->
<echo>Test Results (${}): PASSED!</echo>
Jump to Line
Something went wrong with that request. Please try again.