2010-01-13 17:25:55 -05:00
<?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
2012-01-11 11:40:57 -05:00
2010-01-13 17:25:55 -05:00
http://www.apache.org/licenses/LICENSE-2.0
2012-01-11 11:40:57 -05:00
2010-01-13 17:25:55 -05:00
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
2012-01-11 11:40:57 -05:00
under the License.
2010-01-13 17:25:55 -05:00
-->
<!--
This ANT build file is used to run the JPA 2.0 TCK. It assumes that you have
2010-04-16 10:05:00 -04:00
the TCK, config and patches zip files located at:
2010-01-13 17:25:55 -05:00
2010-12-14 08:59:06 -05:00
${user.home}/.m2/privaterepos/jpatck-2.0_05-Dec-2010.zip
${user.home}/.m2/privaterepos/jpatck-2.0_05-Dec-2010_config.zip
2010-01-13 17:25:55 -05:00
If you have that file in a different location, it can be specified with
2010-09-17 09:00:08 -04:00
the "tck.zip" and "tck_patches.zip" system property.
2010-01-13 17:25:55 -05:00
The TCK running process will do the following:
1. Fine the TCK zip file and extract it
2. Create an openjpa-provider.properties 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.
-->
2012-01-11 11:40:57 -05:00
<!--
Please keep the project tag on one line to avoid confusing
2010-01-13 17:25:55 -05:00
the release plugin.
-->
<project name= "JPA2TCK" default= "run-tck" >
2010-09-15 14:06:25 -04:00
<!-- Import ant - contrib for If/then/else support -->
<taskdef resource= "net/sf/antcontrib/antcontrib.properties" />
2010-01-13 17:25:55 -05:00
<!--
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" >
2010-12-14 08:59:06 -05:00
<property name= "tck.level" value= "jpatck-2.0_05-Dec-2010" />
2010-01-13 17:25:55 -05:00
<property name= "tck.zip" value= "${LOCAL_M2_REPO}/../privaterepos/${tck.level}.zip" />
<available property= "tck.available" file= "${tck.zip}" />
<fail unless= "tck.available" > The TCK file specified in the "tck.zip" system property (${tck.zip}) does not exist. This file must be downloaded separately in order to be able to run the JPA 2.0 TCK</fail>
2010-04-16 10:05:00 -04:00
<property name= "tck_config.zip" value= "${LOCAL_M2_REPO}/../privaterepos/${tck.level}_config.zip" />
<available property= "tck_config.available" file= "${tck_config.zip}" />
<fail unless= "tck_config.available" > The TCK config file specified in the "tck_config.zip" system property (${tck_config.zip}) does not exist. This file must be downloaded separately in order to be able to run the JPA 2.0 TCK</fail>
2010-12-14 08:59:06 -05:00
<!--
2010-09-17 09:00:08 -04:00
<property name= "tck_patches.zip" value= "${LOCAL_M2_REPO}/../privaterepos/${tck.level}_patches.zip" />
<available property= "tck_patches.available" file= "${tck_patches.zip}" />
<fail unless= "tck_patches.available" > The TCK patches file specified in the "tck_patches.zip" system property (${tck_patches.zip}) does not exist. This file must be downloaded separately in order to be able to run the JPA 2.0 TCK</fail>
2010-12-14 08:59:06 -05:00
-->
2010-09-17 09:00:08 -04:00
2010-01-13 17:25:55 -05:00
<delete dir= "${tck.dir}" />
<unzip overwrite= "false" src= "${tck.zip}" dest= "${tck.base}" />
2010-04-16 10:05:00 -04:00
<unzip overwrite= "true" src= "${tck_config.zip}" dest= "${tck.base}" />
2010-12-14 08:59:06 -05:00
<!--
2010-09-17 09:00:08 -04:00
<unzip overwrite= "true" src= "${tck_patches.zip}" dest= "${tck.base}" />
2010-12-14 08:59:06 -05:00
-->
2010-01-13 17:25:55 -05:00
<copy overwrite= "true"
file="${tck.dir}/bin/ts.jte" tofile="${tck.dir}/bin/ts.jte.orig" />
2010-01-14 14:47:44 -05:00
<copy overwrite= "true"
file="${tck.dir}/bin/ts.jtx" tofile="${tck.dir}/bin/ts.jtx.orig" />
2010-01-13 17:25:55 -05:00
<!-- Pluggability tests using Toplink needs this dir created -->
<mkdir dir= "${tck.dir}/domains/domain1/logs" />
2010-04-16 10:05:00 -04:00
<!-- create other missing directory -->
<mkdir dir= "${tck.dir}/weblib" />
2010-01-13 17:25:55 -05:00
</target>
<!--
Target: setup
Description: This updates the TCK configuration for OpenJPA.
-->
<target name= "setup" >
<property name= "db.name" value= "derby" />
<property name= "db.driver" value= "org.apache.derby.jdbc.EmbeddedDriver" />
<property name= "db.url" value= "jdbc:derby:derby-database;create=true" />
<property name= "db.username" value= "nousername" />
<property name= "db.password" value= "nopassword" />
2010-04-14 14:48:27 -04:00
<property name= "openjpa.Log" value= "DefaultLevel=TRACE" />
2010-01-13 17:25:55 -05:00
<property name= "jpatck.test" value= "" />
<property name= "tck.reports" value= "${tck.base}/reports" />
<property name= "tck.work" value= "${tck.base}/work" />
<property name= "openjpa.properties" value= "${tck.dir}/openjpa-provider.properties" />
<property name= "toplink.properties" value= "${tck.dir}/bin/toplink-provider.properties" />
<!-- create the OpenJPA properties for the TCK run -->
<echo append= "false" file= "${openjpa.properties}" >
2023-04-24 03:16:57 -04:00
jakarta.persistence.provider: org.apache.openjpa.persistence.PersistenceProviderImpl
2010-01-13 17:25:55 -05:00
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
2010-04-14 14:48:27 -04:00
openjpa.Log: ${openjpa.Log}
2010-01-13 17:25:55 -05:00
openjpa.jdbc.DBDictionary: StoreCharsAsNumbers=true
openjpa.jdbc.SchemaFactory: native(ForeignKeys=true)
openjpa.jdbc.SynchronizeMappings: buildSchema(ForeignKeys=true)
</echo>
<!-- 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.home=${tck.dir}
work.dir=${tck.work}
report.dir=${tck.reports}
jpa.classes=${cp.property}
# jpa.classes includes Derby, so only set database.classes for other DBs
database.classes=
# different properties needed for pluggability bucket
openjpa.properties=${openjpa.properties}
toplink.properties=${toplink.properties}
# Need to specify java.* classes, both in Windows/UNIX locations as well as Mac.
2012-01-11 11:40:57 -05:00
# This includes a few different possible locations; only one of them needs to
2010-01-13 17:25:55 -05:00
# actually work for a given environment.
sigTestClasspath=${JAVA_HOME}/lib/rt.jar${path.separator}${JAVA_HOME}/jre/lib/rt.jar${path.separator}${JAVA_HOME}/../Classes/classes.jar${path.separator}$${jpa.classes}
persistence.unit.properties.file.full.path=${provider.properties}
database.user=${db.username}
database.passwd=${db.password}
database.url=${db.url}
database.driver=${db.driver}
databaseName=${db.name}
</echo>
<!-- convert backslashes and known paths with spaces
2012-01-11 11:40:57 -05:00
to get around a problem with the TCK testrunner
2010-01-13 17:25:55 -05:00
on windows -->
<echo > Update directory paths if running on Windows</echo>
<replace summary= "yes" file= "${jpatck.config}.tmp" replacefilterfile= "windows-replacefilter.properties" />
<!-- 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" />
</concat>
<path id= "agent.path" >
<fileset dir= "../../openjpa/target" >
<include name= "*.jar" />
<exclude name= "*-sources.jar" />
<exclude name= "original-*.jar" />
<exclude name= "*-tests.jar" />
<exclude name= "*-javadoc.jar" />
</fileset>
</path>
<pathconvert dirsep= "/" property= "agent" refid= "agent.path" />
<property name= "agent.properties" value= "" />
<echo > AGENT: ${agent}${agent.properties}</echo>
<!--
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}${agent.properties} -Dopenjpa.MetaDataFactory=jpa(DefaultAccessType=PROPERTY)" />
</replace>
<!-- Fix path for java.security.policy -->
<replace file= "${jpatck.config}" >
<replacefilter token= "-Djava.security.policy=${bin.dir}/harness.policy" value= "-Djava.security.policy=${ts.home}/bin/harness.policy" />
</replace>
<!-- cleanup reports/work dirs from any prior runs -->
<delete dir= "${tck.reports}" />
<delete dir= "${tck.work}" />
<echo > Logging JPA 2.0 TCK output to ${tck.log}</echo>
</target>
<!--
Macro for the TCK harness launcher
-->
<macrodef name= "tsant" >
2010-09-15 14:06:25 -04:00
<attribute name= "dir" default= "${tck.dir}/src" />
2010-01-13 17:25:55 -05:00
<attribute name= "buildfile" />
<attribute name= "target" />
2012-01-12 10:12:58 -05:00
<attribute name= "tmo" default= "7200000" />
2010-01-13 17:25:55 -05:00
<sequential >
2012-01-12 10:12:58 -05:00
<java classname= "org.apache.tools.ant.launch.Launcher" fork= "true" failonerror= "false" dir= "@{dir}" append= "true" output= "${tck.log}" timeout= "@{tmo}" resultproperty= "tsant.result" >
2010-01-13 17:25:55 -05:00
<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" />
<!--
2010-09-15 14:06:25 -04:00
<sysproperty key= "pkg.dir" value= "${jpatck.pkg.dir}" />
2010-01-13 17:25:55 -05:00
<sysproperty key= "test" value= "${jpatck.test}" />
-->
<classpath >
<path refid= "cp" />
<fileset dir= "${tck.dir}/tools/ant/lib" >
<include name= "**/*.jar" />
</fileset>
<fileset dir= "${tck.dir}/lib" >
<include name= "**/*.jar" />
</fileset>
</classpath>
</java>
</sequential>
</macrodef>
<!--
Macro to determine how many tests passed/failed
-->
2010-01-13 21:38:55 -05:00
<macrodef name= "results.count" >
2010-01-13 17:25:55 -05:00
<!-- Figure out the Passed/Failed counts -->
<sequential >
<resourcecount property= "count.passed" >
<tokens >
<concat >
<filterchain >
<tokenfilter >
<containsstring contains= "Passed." />
</tokenfilter>
</filterchain>
<fileset dir= "${tck.reports}" includes= "summary.txt" />
</concat>
</tokens>
</resourcecount>
<resourcecount property= "count.failed" >
<tokens >
<concat >
<filterchain >
<tokenfilter >
<containsstring contains= "Failed." />
</tokenfilter>
</filterchain>
<fileset dir= "${tck.reports}" includes= "summary.txt" />
</concat>
</tokens>
</resourcecount>
<echo > TCK Results - Passed: ${count.passed}, Failed: ${count.failed}</echo>
</sequential>
</macrodef>
<!--
Target: run-tck
Description: This is the main routine that runs the TCK, after
all other setup steps have been performed.
-->
<target name= "run-tck" >
2010-09-15 14:06:25 -04:00
<echo > Running JPA 2.0 TCK tests</echo>
2010-01-13 17:25:55 -05:00
<echo > Init must have been called before running this target!</echo>
<property name= "tck.log" value= "${tck.base}/openjpa-tck.log" />
<property name= "provider.properties" value= "${openjpa.properties}" />
<!-- 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= "cp.property" value= "${OPENJPA_CLASSPATH}" />
</antcall>
<!-- backup our updated ts.jte for later debugging -->
<copy overwrite= "true"
file="${tck.dir}/bin/ts.jte" tofile="${tck.base}/ts.jte.tck" />
2010-09-17 09:00:08 -04:00
<!-- 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>
2010-01-13 17:25:55 -05:00
<!-- first initialize the database -->
<echo > Calling TCK initdb.xml</echo>
<tsant buildfile= "${tck.dir}/bin/initdb.xml" target= "init.database" />
<echo > TCK initdb.xml returned result=${tsant.result}</echo>
2012-01-12 10:12:58 -05:00
<property name= "jpatck.run.tmo" value= "7200000" />
2010-01-13 17:25:55 -05:00
<!-- now run the TCK -->
2010-09-15 14:06:25 -04:00
<if >
<isset property= "jpatck.pkg.dir" />
<then >
<echo > Calling TCK build.xml for pkg.dir=${jpatck.pkg.dir}</echo>
<property name= "dir" value= "${tck.dir}/src/${jpatck.pkg.dir}" />
2012-01-12 10:12:58 -05:00
<tsant dir= "${dir}" buildfile= "${dir}/build.xml" target= "runclient" tmo= "${jpatck.run.tmo}" />
2010-09-15 14:06:25 -04:00
</then>
<else >
<echo > Calling TCK build.xml for ALL tests</echo>
2012-01-12 10:12:58 -05:00
<tsant buildfile= "${tck.dir}/bin/build.xml" target= "run.all.tests" tmo= "${jpatck.run.tmo}" />
2010-09-15 14:06:25 -04:00
</else>
</if>
2010-01-13 17:25:55 -05:00
<echo > TCK build.xml returned result=${tsant.result}</echo>
<!-- archive the results and check for test failures -->
<antcall target= "zip-artifacts" >
<param name= "results.name" value= "tck" />
2012-01-11 11:40:57 -05:00
</antcall>
2010-01-13 17:25:55 -05:00
</target>
<!--
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"
file="${tck.reports}/summary.txt"
tofile="${tck.base}/summary-${results.name}.txt" />
<property name= "tck.results.archive" value= "${tck.base}/openjpa-${results.name}-results.zip" />
<!-- archive the results -->
<zip destfile= "${tck.results.archive}" >
<fileset dir= "${tck.work}" />
<fileset dir= "${tck.reports}" />
<fileset dir= "${tck.base}" >
<include name= "*${results.name}.log" />
<include name= "*${results.name}.txt" />
<include name= "ts.jte.${results.name}" />
</fileset>
</zip>
<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.
-->
2010-01-13 21:38:55 -05:00
<results.count />
2010-01-13 17:25:55 -05:00
<loadfile property= "jpatck.results" srcfile= "${tck.work}/jtData/log.txt" />
<condition property= "jpatck.failed" >
<contains string= "${jpatck.results}" substring= "Completed test run: not ok" />
</condition>
2010-01-13 21:38:55 -05:00
<fail if= "jpatck.failed" > Test Results (${results.name}): FAILED ${count.failed} tests!</fail>
2010-01-13 17:25:55 -05:00
<!-- else -->
2010-01-13 21:38:55 -05:00
<echo > Test Results (${results.name}): PASSED!</echo>
2010-01-13 17:25:55 -05:00
</target>
</project>