Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 164357 Details for
Bug 301295
WDF test framework is better to be enhanced in order to run all WDF tests on application servers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch submitted
bug301295.patch (text/plain), 97.35 KB, created by
Adrian Goerler
on 2010-04-09 07:49:27 EDT
(
hide
)
Description:
patch submitted
Filename:
MIME Type:
Creator:
Adrian Goerler
Created:
2010-04-09 07:49:27 EDT
Size:
97.35 KB
patch
obsolete
>Index: build.xml >=================================================================== >--- build.xml (revision 6940) >+++ build.xml (working copy) >@@ -99,6 +99,7 @@ > <echo message="user.home = '${user.home}'"/> > <echo message="Loading user properties from: '${user.home}/build.properties'"/> > <property file="${user.home}/build.properties"/> >+ <property file="${user.home}/test.properties"/> > <!-- Sets default junit.lib and all extensions.depend dir locations to static paths --> > <!-- temporary until all build files reworked --> > <property name="oracle.extensions.depend.dir" value="${trunk.build.location}/../extension.oracle.lib.external"/> >Index: jpa/eclipselink.jpa.test/jboss.properties >=================================================================== >--- jpa/eclipselink.jpa.test/jboss.properties (revision 6940) >+++ jpa/eclipselink.jpa.test/jboss.properties (working copy) >@@ -19,6 +19,9 @@ > #persistence10.jar=${jboss.server}/lib/ejb3-persistence.jar > > ## JBoss 5.1.x specific properties. >-jboss.home=../../../jboss-5.1.0.GA >+jboss.home=C:/jboss-5.1.0.GA > server.testrunner=TestRunner/remote-org.eclipse.persistence.testing.framework.server.TestRunner >+server.testrunner.wdf=ServerTestRunnerImpl/remote-org.eclipse.persistence.testing.framework.wdf.server.ServerTestRunner > persistence10.jar=${jboss.home}/common/lib/ejb3-persistence.jar >+ >+ >Index: jpa/eclipselink.jpa.test/netweaver.properties >=================================================================== >--- jpa/eclipselink.jpa.test/netweaver.properties (revision 6940) >+++ jpa/eclipselink.jpa.test/netweaver.properties (working copy) >@@ -44,6 +44,7 @@ > # DO NOT CHANGE > #################################### > server.testrunner=JavaEE/servertest/REMOTE/TestRunner/org.eclipse.persistence.testing.framework.server.TestRunner >+server.testrunner.wdf=JavaEE/servertest/REMOTE/ServerTestRunnerImpl/org.eclipse.persistence.testing.framework.wdf.server.ServerTestRunner > server.lib=${netweaver.instance.dir}/j2ee/j2eeclient > server.platform=NetWeaver_7_1 > #server.platform=org.eclipse.persistence.platform.server.sap.SAPNetWeaver_7_1_Platform >@@ -57,3 +58,4 @@ > netweaver.deployment.dir=${netweaver.instance.dir}/j2ee/deployment > netweaver.deployment.ant.dir=${netweaver.deployment.dir}/ant/lib > eclipselink.home=../.. >+extensions.home=../../../incubator/extensions/trunk >\ No newline at end of file >Index: jpa/eclipselink.jpa.wdf.test/build.xml >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/build.xml (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/build.xml (working copy) >@@ -29,12 +29,13 @@ > * - Ant properties are lower case. > * > * Contributors: >-* tware - initial API and implementation >-* egwin Update and add to nightly process. >+* tware - initial API and implementation >+* egwin Update and add to nightly process. >+* agoerler prepare for server-tests > #******************************************************************************/--> > > <!-- This ant project includes the following tasks: >- - all (default) : compiles all JPA tests, packages test jars >+ - build (default) : compiles all JPA tests, packages test jars > - compile : compiles all JPA tests > - package : jars JPA persistent units and tests jars > - test : runs als JPA WDF tests >@@ -63,6 +64,7 @@ > <property name="wdf_test.2.moxy.dir" value="${wdf_test.2.trunk.dir}/moxy/org.eclipse.persistence.moxy"/> > <property name="wdf_test.2.core.test.dir" value="${wdf_test.2.trunk.dir}/foundation/eclipselink.core.test"/> > <property name="env" environment="env" value="env"/> >+ <property name="eclipselink.jpa.test" value="../eclipselink.jpa.test"/> > > <!-- Allows a user to overide certain user specific properties. --> > <property file="${user.home}/build.properties"/> >@@ -76,9 +78,10 @@ > <target name="build-against-jar" depends="clean, init_against_jar, compile, package" description="build JPA WDF testing jars"/> > <target name="build-against-classes" depends="clean, init_against_classes, compile, package" description="build JPA WDF testing jars"/> > <target name="build-against-bundles" depends="clean, init_against_bundles, compile, package" description="build JPA WDF testing jars"/> >- <target name="test-against-jar" depends="clean-test, init_against_jar, init_runtime, test-lrg" description="run JPA WDF tests"/> >+ <target name="test-against-jar" depends="clean-test, init_against_jar, init_runtime, test-lrg" description="run JPA WDF tests"/> > <target name="test-against-classes" depends="clean-test, init_against_classes, init_runtime, test-lrg" description="run JPA WDF tests"/> > <target name="test-against-bundles" depends="clean-test, init_against_bundles, init_runtime, test-lrg" description="run JPA WDF tests"/> >+ <target name="server-test" depends="server-test-internal" description="run JPA WDF tests on server configured by property server.name"/> > <!-- convienience targets --> > <target name="build" depends="build-against-jar"/> > <target name="test" depends="test-against-jar"/> >@@ -100,11 +103,11 @@ > <pathelement path="${wdf_test.2.core.test.dir}/${classes.dir}"/> > <pathelement path="${wdf_test.2.core.test.dir}/${eclipselink.tests.jar}"/> > <pathelement path="${wdf_test.2.jpa.plugins.dir}/${persistence20.jar}"/> >+ <pathelement path="${wdf_test.2.common.plugins.dir}/${ejb.jar}"/> > <!-- These paths are unneeded for compile or run (from core.depend) may be needed in future --> > <!-- pathelement path="${wdf_test.2.common.plugins.dir}/${unsigned.persistence10.jar}"/ --> > <!-- pathelement path="${wdf_test.2.common.plugins.dir}/${activation.jar}"/ --> > <!-- pathelement path="${wdf_test.2.common.plugins.dir}/${resource.jar}"/ --> >- <!-- pathelement path="${wdf_test.2.common.plugins.dir}/${ejb.jar}"/ --> > <!-- pathelement path="${wdf_test.2.common.plugins.dir}/${jms.jar}"/ --> > <!-- pathelement path="${wdf_test.2.common.plugins.dir}/${stax_api.jar}"/ --> > <!-- pathelement path="${wdf_test.2.common.plugins.dir}/${mail.jar}"/ --> >@@ -178,33 +181,108 @@ > <path refid="compile.path"/> > </classpath> > </javac> >+ <javac >+ srcdir="${wdf_test.2.core.test.dir}/${src.dir}" >+ destdir="${classes.dir}" >+ debug="${javac.debug}" >+ debuglevel="${javac.debuglevel}" >+ optimize="${javac.optimize}" >+ source="${javac.version}" >+ target="${javac.version}" >+ deprecation="${javac.deprecation}" >+ failonerror="true" >+ includes="org/eclipse/persistence/testing/framework/junit/**, >+ org/eclipse/persistence/testing/framework/AutoVerifyTestCase.java, >+ org/eclipse/persistence/testing/framework/TestCase.java, >+ org/eclipse/persistence/testing/framework/TestEntity.java, >+ org/eclipse/persistence/testing/framework/TestModel.java, >+ org/eclipse/persistence/testing/framework/*TestHelper.java, >+ org/eclipse/persistence/testing/framework/QuerySQLTracker.java, >+ org/eclipse/persistence/testing/framework/TestWarningException.java, >+ org/eclipse/persistence/testing/framework/TestException.java, >+ org/eclipse/persistence/testing/framework/TestErrorException.java, >+ org/eclipse/persistence/testing/framework/TestProblemException.java, >+ org/eclipse/persistence/testing/framework/ResultInterface.java, >+ org/eclipse/persistence/testing/framework/TestCollection.java, >+ org/eclipse/persistence/testing/framework/PerformanceComparisonTest.java, >+ org/eclipse/persistence/testing/framework/PerformanceComparisonTestCase.java, >+ org/eclipse/persistence/testing/framework/TestResult.java, >+ org/eclipse/persistence/testing/framework/PerformanceComparisonTestResult.java, >+ org/eclipse/persistence/testing/framework/PerformanceRegressionTest.java, >+ org/eclipse/persistence/testing/framework/PerformanceRegressionTestCase.java, >+ org/eclipse/persistence/testing/framework/ConcurrencyTestAdapter.java, >+ org/eclipse/persistence/testing/framework/ConcurrentPerformanceComparisonTest.java, >+ org/eclipse/persistence/testing/framework/ConcurrentPerformanceRegressionTest.java"> >+ <classpath refid="compile.path"/> >+ </javac> > </target> >+ >+ <target name="get-server-properties"> >+ <property file="${user.home}/${server.name}.properties"/> >+ <property file="${eclipselink.jpa.test}/${server.name}.properties"/> >+ <echo message="server.lib=${server.lib}"/> >+ <echo message="server.depend=${server.depend}"/> >+ <echo message="server.name=${server.name}"/> >+ <echo message="server.platform=${server.platform}"/> >+ </target> > > <!-- Packages JPA persistent unit test jars. --> >- <target name="package" depends="package-wdf-jpa2-model, package-wdf-jpa1-model" description="build EclipseLink jar"> >+ <target name="package" depends="package-tests, package-wdf-jpa2-model, package-wdf-jpa1-model" description="build EclipseLink jar"/> >+ >+ >+ <target name="package-tests" depends="get-server-properties"> >+ <mkdir dir="${wdf_test.build.location}/stage"/> >+ <filter token="server.user" value="${server.user}"/> >+ <filter token="server.pwd" value="${server.pwd}"/> >+ <filter token="server.factory" value="${server.factory}"/> >+ <echo message="eclipselink.jpa.test=${eclipselink.jpa.test}"/> >+ >+ <copy file="${wdf_test.build.location}/../eclipselink.jpa.test/resource/server/jndi.properties" todir="stage" filtering="true"/> >+ > <jar jarfile="${wdf_test.build.location}/${eclipselink.tests.jar}"> >+ <zipfileset dir="${wdf_test.build.location}/resource/ejb" includes="*.xml" prefix="META-INF"/> > <fileset dir="${wdf_test.build.location}/${classes.dir}" > includes="org/eclipse/persistence/testing/framework/**/*.class, > org/eclipse/persistence/testing/tests/**/*.class"/> >+ <fileset dir="${wdf_test.build.location}/stage" >+ includes="jndi.properties"/> > </jar> >+ <delete dir="stage"/> > </target> > >- <target name="package-wdf-jpa2-model"> >- <jar jarfile="${wdf_test.build.location}/${eclipselink.wdf.jpa2.model}.jar"> >- <zipfileset dir="${wdf_test.build.location}/resource/${eclipselink.wdf.jpa2.model}" includes="*.xml" prefix="META-INF"/> >+ <target name="package-model" depends="get-server-properties,set-app-name"> >+ <copy overwrite="true" file="${wdf_test.build.location}/resource/${MODEL}/persistence.xml" todir="${build.dir}/META-INF"/> >+ <replace dir="${build.dir}/META-INF" token='%%database-platform%%' value="${db.platform}"> >+ <include name="persistence.xml"/> >+ </replace> >+ <replace dir="${build.dir}/META-INF" token='%%data-source-name%%' value="${DS_NAME}"> >+ <include name="persistence.xml"/> >+ </replace> >+ <replace dir="${build.dir}/META-INF" token='%%server-platform%%' value="${server.platform}"> >+ <include name="persistence.xml"/> >+ </replace> >+ <jar jarfile="${wdf_test.build.location}/${MODEL}.jar"> >+ <zipfileset dir="${build.dir}/META-INF" includes="*.xml" prefix="META-INF"/> > <fileset dir="${wdf_test.build.location}/${classes.dir}" >- includes="org/eclipse/persistence/testing/models/wdf/jpa2/**"/> >+ includes="${PACKAGE}"/> > </jar> >+ <delete dir="${build.dir}/META-INF"/> > </target> > > <target name="package-wdf-jpa1-model"> >- <jar jarfile="${wdf_test.build.location}/${eclipselink.wdf.jpa1.model}.jar"> >- <zipfileset dir="${wdf_test.build.location}/resource/${eclipselink.wdf.jpa1.model}" includes="*.xml" prefix="META-INF"/> >- <fileset dir="${wdf_test.build.location}/${classes.dir}" >- includes="org/eclipse/persistence/testing/models/wdf/jpa1/**"/> >- </jar> >+ <antcall target="package-model"> >+ <param name="MODEL" value="${eclipselink.wdf.jpa1.model}"/> >+ <param name="PACKAGE" value="org/eclipse/persistence/testing/models/wdf/jpa1/**"/> >+ </antcall> > </target> > >+ <target name="package-wdf-jpa2-model"> >+ <antcall target="package-model"> >+ <param name="MODEL" value="${eclipselink.wdf.jpa2.model}"/> >+ <param name="PACKAGE" value="org/eclipse/persistence/testing/models/wdf/jpa2/**"/> >+ </antcall> >+ </target> >+ > <!-- Testing --> > > <!-- Clean all build generated content. --> >@@ -227,14 +305,15 @@ > </target> > > <!-- Default test target, run the LRG --> >- <target name="test-lrg" depends="clean-test"> >+ <target name="test-lrg"> > <antcall target="run-test" inheritRefs="true"> > <param name="TEST_CLASS" value="${test.class}"/> >- <param name="TEST_AGENT" value="${test.agent}"/> >- <param name="TEST_WEAVING" value="${test.weaving}"/> >+ <param name="TEST_AGENT" value="${test.agent}"/> >+ <param name="TEST_WEAVING" value="${test.weaving}"/> > <param name="ORM_TESTING" value="-Dorm.testing=jpa"/> > <param name="RUN_PATH" value="run.path"/> > <param name="DB_URL" value="${db.url}"/> >+ <param name="SERVER" value="false"/> > </antcall> > <antcall target="generate-report" inheritRefs="true"/> > </target> >@@ -260,6 +339,10 @@ > <jvmarg value="-Ddb.user=${db.user}"/> > <jvmarg value="-Ddb.pwd=${db.pwd}"/> > <jvmarg value="${jvmarg.db.platform}"/> >+ <jvmarg value="-Dservertest=${SERVER}"/> >+ <sysproperty key="server.url" value="${server.url}${APP_NAME}"/> >+ <sysproperty key="server.testrunner.wdf" value="${server.testrunner.wdf}"/> >+ <sysproperty key="datasource.name" value="${DS_LOOKUP_NAME}"/> > <classpath> > <path refid="${RUN_PATH}"/> > </classpath> >@@ -281,4 +364,113 @@ > </junitreport> > </target> > >+ >+ <!-- Build server test ear. --> >+ <target name="server-build-ear" depends="build-against-jar" > >+ <copy overwrite="true" file="./resource/ear/application.xml" todir="${build.dir}/META-INF"/> >+ <ear destfile="${wdf_test.build.location}/${build.dir}/servertest.ear" appxml="${build.dir}/META-INF/application.xml"> >+ <fileset file="${wdf_test.build.location}/${eclipselink.tests.jar}"/> >+ <zipfileset dir="${wdf_test.build.location}" includes="${eclipselink.wdf.jpa1.model}.jar" prefix="${LIB_PREFIX}"/> >+ </ear> >+ <copy file="${wdf_test.build.location}/${build.dir}/servertest.ear" todir="${basedir}"/> >+ </target> >+ >+ <target name="server-deploy"> >+ <ant antfile="${eclipselink.jpa.test}/${server.name}.xml" target="${server.name}-deploy" inheritRefs="true"> >+ <property name="ear.name" value="${ear.name}"/> >+ <property name="application.name" value="${application.name}"/> >+ </ant> >+ </target> >+ >+ <target name="server-undeploy"> >+ <ant antfile="${eclipselink.jpa.test}/${server.name}.xml" target="${server.name}-undeploy" inheritRefs="true"> >+ <property name="application.name" value="${application.name}"/> >+ </ant> >+ </target> >+ >+ <!-- Allows we run websphere tests from Windows & Linux both. --> >+ <target name="detect-os"> >+ <condition property="is.windows" value="true"> >+ <os family="windows"/> >+ </condition> >+ <condition property="is.unix" value="true"> >+ <os family="unix"/> >+ </condition> >+ <condition property="suffix" value="bat"> >+ <isset property="is.windows"/> >+ </condition> >+ <condition property="suffix" value="sh"> >+ <isset property="is.unix"/> >+ </condition> >+ <echo message="suffix=${suffix}"/> >+ </target> >+ >+ >+ <target name="set-app-name" depends="detect-os"> >+ <condition property="APP_NAME" value=""> >+ <contains string="${server.name}" substring="websphere"/> >+ </condition> >+ <condition property="APP_NAME" value="servertest"> >+ <not> >+ <isset property="is.websphere"/> >+ </not> >+ </condition> >+ >+ <condition property="DS_NAME" value="java:/EclipseLinkDS"> >+ <contains string="${server.name}" substring="jboss"/> >+ </condition> >+ <condition property="DS_NAME" value="jdbc/EclipseLinkDS"> >+ <not> >+ <isset property="is.jboss"/> >+ </not> >+ </condition> >+ >+ <condition property="DS_LOOKUP_NAME" value="jdbc/${DS_NAME}"> >+ <contains string="${server.name}" substring="netweaver"/> >+ </condition> >+ <condition property="DS_LOOKUP_NAME" value="${DS_NAME}"> >+ <not> >+ <isset property="is.netweaver"/> >+ </not> >+ </condition> >+ >+ >+ <condition property="LIB_PREFIX" value=""> >+ <contains string="${server.name}" substring="netweaver"/> >+ </condition> >+ <condition property="LIB_PREFIX" value="lib"> >+ <not> >+ <isset property="is.netweaver"/> >+ </not> >+ </condition> >+ </target> >+ >+ <!-- Build, deploy and run a test suite on the server. --> >+ <target name="server-test-internal" depends="get-server-properties, detect-os, set-app-name, server-build-ear, init_runtime"> >+ <antcall target="server-deploy" inheritRefs="true"> >+ <param name="ear.name" value="servertest.ear"/> >+ <param name="application.name" value="servertest"/> >+ </antcall> >+ <path id="run.path.server"> >+ <fileset dir="${server.lib}" includes="${server.depend}"/> >+ <path refid="run.path"/> >+ </path> >+ <antcall target="run-test" inheritRefs="true"> >+ <param name="TEST_CLASS" value="${test.class}"/> >+ <param name="TEST_AGENT" value="${test.agent}"/> >+ <param name="TEST_WEAVING" value="${test.weaving}"/> >+ <param name="ORM_TESTING" value="-Dorm.testing=jpa"/> >+ <param name="RUN_PATH" value="run.path.server"/> >+ <param name="DB_URL" value="${db.url}"/> >+ <param name="SERVER" value="true"/> >+ </antcall> >+ <antcall target="generate-report" inheritRefs="true"/> >+ <antcall target="server-undeploy" inheritRefs="true"> >+ <param name="application.name" value="servertest"/> >+ </antcall> >+ </target> >+ >+ > </project> >+ >+ >Index: jpa/eclipselink.jpa.wdf.test/resource/ear/application.xml >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/resource/ear/application.xml (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/resource/ear/application.xml (revision 0) >@@ -0,0 +1,13 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+ >+<application xmlns="http://java.sun.com/xml/ns/javaee" >+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee >+ http://java.sun.com/xml/ns/javaee/application_5.xsd" >+ version="5"> >+ <description>servertest</description> >+ <display-name>servertest</display-name> >+ <module> >+ <ejb>eclipselink-tests.jar</ejb> >+ </module> >+</application> >Index: jpa/eclipselink.jpa.wdf.test/resource/eclipselink-wdf-jpa1-model/persistence.xml >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/resource/eclipselink-wdf-jpa1-model/persistence.xml (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/resource/eclipselink-wdf-jpa1-model/persistence.xml (working copy) >@@ -2,9 +2,10 @@ > <persistence version="1.0" > xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> >- <persistence-unit name="jpa1testmodel"> >+ <persistence-unit name="jpa1testmodel" transaction-type="RESOURCE_LOCAL"> > <description>ATS Test Persistence Unit</description> >- <jta-data-source>JPA2_TEST</jta-data-source> >+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >+ <non-jta-data-source>%%data-source-name%%</non-jta-data-source> > <class>org.eclipse.persistence.testing.models.wdf.jpa1.component.Component</class> > <class>org.eclipse.persistence.testing.models.wdf.jpa1.component.Metric</class> > <class>org.eclipse.persistence.testing.models.wdf.jpa1.component.MetricFloat</class> >@@ -83,11 +84,28 @@ > > <exclude-unlisted-classes>true</exclude-unlisted-classes> > <properties> >- <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/> >- <property name="eclipselink.cache.shared.default" value="false"/> >- <property name="eclipselink.temporal.mutable" value="true"/> >- <property name="eclipselink.weaving" value="false"/> >+ <property name="eclipselink.target-server" value="%%server-platform%%"/> >+ <property name="eclipselink.target-database" value="%%database-platform%%"/> >+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/> >+ <property name="eclipselink.cache.shared.default" value="false"/> >+ <property name="eclipselink.temporal.mutable" value="true"/> >+ <property name="eclipselink.weaving" value="false"/> > </properties> > </persistence-unit> >+ <!-- >+ <persistence-unit name="jpa1testmodel_jta"> >+ <description>ATS Test Persistence Unit</description> >+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >+ <jta-data-source>jdbc/EclipseLinkDS</jta-data-source> >+ <properties> >+ <property name="eclipselink.target-server" value="%%server-platform%%"/> >+ <property name="eclipselink.target-database" value="%%database-platform%%"/> >+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/> >+ <property name="eclipselink.cache.shared.default" value="false"/> >+ <property name="eclipselink.temporal.mutable" value="true"/> >+ <property name="eclipselink.weaving" value="false"/> >+ </properties> >+ </persistence-unit> >+ --> > </persistence> > >Index: jpa/eclipselink.jpa.wdf.test/resource/eclipselink-wdf-jpa2-model/persistence.xml >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/resource/eclipselink-wdf-jpa2-model/persistence.xml (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/resource/eclipselink-wdf-jpa2-model/persistence.xml (working copy) >@@ -2,9 +2,10 @@ > <persistence version="2.0" > xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> >- <persistence-unit name="jpa2testmodel"> >+ <persistence-unit name="jpa2testmodel" transaction-type="RESOURCE_LOCAL"> > <description>ATS Test Persistence Unit</description> >- <jta-data-source>JPA2_TEST</jta-data-source> >+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> >+ <jta-data-source>jdbc/EclipseLinkDS</jta-data-source> > <class>org.eclipse.persistence.testing.models.wdf.jpa2.employee.Address</class> > <class>org.eclipse.persistence.testing.models.wdf.jpa2.employee.ContactInfo</class> > <class>org.eclipse.persistence.testing.models.wdf.jpa2.employee.Department</class> >@@ -22,8 +23,12 @@ > <class>org.eclipse.persistence.testing.models.wdf.jpa2.embedded.EmbeddingPropertyAccess</class> > <exclude-unlisted-classes>true</exclude-unlisted-classes> > <properties> >- <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/> >- <property name="eclipselink.cache.shared.default" value="false"/> >+ <!--<property name="eclipselink.target-server" value="org.eclipse.persistence.platform.server.sap.SAPNetWeaver_7_1_Platform"/> --> >+ <property name="eclipselink.target-database" value="%%database-platform%%"/> >+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/> >+ <property name="eclipselink.cache.shared.default" value="false"/> >+ <property name="eclipselink.temporal.mutable" value="true"/> >+ <property name="eclipselink.weaving" value="false"/> > </properties> > </persistence-unit> > </persistence> >Index: jpa/eclipselink.jpa.wdf.test/resource/ejb/ejb-jar.xml >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/resource/ejb/ejb-jar.xml (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/resource/ejb/ejb-jar.xml (revision 0) >@@ -0,0 +1,38 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" >+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee >+ http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" >+ version="3.0"> >+ <enterprise-beans> >+ <session> >+ <ejb-name>ServerTestRunnerImpl</ejb-name> >+ <persistence-unit-ref> >+ <persistence-unit-ref-name>persistence/jpa1testmodel_rl/factory</persistence-unit-ref-name> >+ <persistence-unit-name>jpa1testmodel</persistence-unit-name> >+ </persistence-unit-ref> >+ <!-- >+ <persistence-unit-ref> >+ <persistence-unit-ref-name>persistence/jpa1testmodel_jta/factory</persistence-unit-ref-name> >+ <persistence-unit-name>../lib/eclipselink-wdf-jpa1-model.jar#jpa1testmodel_jta</persistence-unit-name> >+ </persistence-unit-ref> >+ <persistence-unit-ref> >+ <persistence-unit-ref-name>persistence/jpa2testmodel_rl/factory</persistence-unit-ref-name> >+ <persistence-unit-name>../lib/eclipselink-wdf-jpa2-model.jar#jpa2testmodel</persistence-unit-name> >+ </persistence-unit-ref> >+ <persistence-context-ref> >+ <persistence-context-ref-name>persistence/jpa2testmodel_rl/entity-manager</persistence-context-ref-name> >+ <persistence-unit-name>../lib/eclipselink-wdf-jpa2-model.jar#jpa2testmodel</persistence-unit-name> >+ </persistence-context-ref> >+ <persistence-context-ref> >+ <persistence-context-ref-name>persistence/jpa1testmodel_rl/entity-manager</persistence-context-ref-name> >+ <persistence-unit-name>../lib/eclipselink-wdf-jpa1-model.jar#jpa1testmodel</persistence-unit-name> >+ </persistence-context-ref> >+ <persistence-context-ref> >+ <persistence-context-ref-name>persistence/jpa1testmodel_jta/entity-manager</persistence-context-ref-name> >+ <persistence-unit-name>../lib/eclipselink-wdf-jpa1-model.jar#jpa1testmodel_jta</persistence-unit-name> >+ </persistence-context-ref> >+ --> >+ </session> >+ </enterprise-beans> >+</ejb-jar> >\ No newline at end of file >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/server/JEEPlatform.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/server/JEEPlatform.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/server/JEEPlatform.java (working copy) >@@ -91,7 +91,7 @@ > > public UserTransaction getUserTransaction() { > try { >- return (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction"); >+ return (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction"); > } catch (NamingException exception) { > throw new RuntimeException(exception); > } >@@ -158,7 +158,7 @@ > if (entityManagerFactory != null) { > return entityManagerFactory; > } >- String contextName = "java:comp/env/persistence/" + persistenceUnit + "/factory"; >+ String contextName = "java:comp/env/persistence/" + persistenceUnit + "_rl/factory"; > try { > return (EntityManagerFactory) new InitialContext().lookup(contextName); > } catch (NamingException exception) { >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/AbstractBaseTest.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/AbstractBaseTest.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/AbstractBaseTest.java (working copy) >@@ -26,20 +26,25 @@ > import java.sql.Statement; > import java.util.HashMap; > import java.util.HashSet; >+import java.util.Hashtable; > import java.util.Locale; > import java.util.Map; > import java.util.Properties; > import java.util.Set; > >+import javax.naming.Context; >+import javax.naming.InitialContext; > import javax.naming.NamingException; > import javax.persistence.EntityManager; > import javax.persistence.EntityManagerFactory; >+import javax.persistence.LockModeType; > import javax.persistence.Persistence; > import javax.sql.DataSource; > > import org.eclipse.persistence.config.PersistenceUnitProperties; >-import org.eclipse.persistence.testing.framework.junit.JUnitTestCase; > import org.eclipse.persistence.testing.framework.junit.JUnitTestCaseHelper; >+import org.eclipse.persistence.testing.framework.server.JEEPlatform; >+import org.eclipse.persistence.testing.framework.server.ServerPlatform; > import org.eclipse.persistence.testing.tests.feature.TestDataSource; > import org.junit.Assert; > import org.junit.Before; >@@ -48,33 +53,58 @@ > > @SuppressWarnings("unchecked") > @RunWith(SkipBugzillaTestRunner.class) >-public abstract class AbstractBaseTest extends JUnitTestCase { >+public abstract class AbstractBaseTest { > >+ // /** System variable to set the tests to run on the server. */ >+ // public static final String RUN_ON_SERVER = "server.run"; >+ // >+ private static Map<String, EntityManagerFactory> emfNamedPersistenceUnits = new Hashtable<String, EntityManagerFactory>(); >+ >+ /** Determine if the test is running on a JEE server, or in JSE. */ >+ >+ private static ServerPlatform serverPlatform; >+ > private final JPAEnvironment environment; > private final String puName; > private final static DataSource dataSource; > private final static Map EMF_PROPERTIES; > >+ private static boolean seesJPA2 = (LockModeType.values().length > 2); >+ > static { >- Map<String, String> properties = JUnitTestCaseHelper.getDatabaseProperties(); >- String driver = properties.get(PersistenceUnitProperties.JDBC_DRIVER); >- String url = properties.get(PersistenceUnitProperties.JDBC_URL); >- String user = properties.get(PersistenceUnitProperties.JDBC_USER); >- String password = properties.get(PersistenceUnitProperties.JDBC_PASSWORD); >+ final DataSource aDataSource; > >- Properties userPasswd = new Properties(); >- userPasswd.put("user", user); >- userPasswd.put("password", password); >+ if (!ServerInfoHolder.isOnServer()) { >+ Map<String, String> properties = JUnitTestCaseHelper.getDatabaseProperties(); >+ String driver = properties.get(PersistenceUnitProperties.JDBC_DRIVER); >+ String url = properties.get(PersistenceUnitProperties.JDBC_URL); >+ String user = properties.get(PersistenceUnitProperties.JDBC_USER); >+ String password = properties.get(PersistenceUnitProperties.JDBC_PASSWORD); > >- DataSource ds = new TestDataSource(driver, url, userPasswd); >- dataSource = new PooledDataSource(ds); >+ Properties userPasswd = new Properties(); >+ userPasswd.put("user", user); >+ userPasswd.put("password", password); >+ >+ DataSource ds = new TestDataSource(driver, url, userPasswd); >+ aDataSource = new PooledDataSource(ds); >+ >+ } else { >+ Context context; >+ try { >+ context = new InitialContext(); >+ aDataSource = (DataSource) context.lookup(ServerInfoHolder.getDataSourceName()); >+ } catch (NamingException e) { >+ throw new RuntimeException(e); >+ } >+ } >+ dataSource = aDataSource; > EMF_PROPERTIES = new HashMap(); > EMF_PROPERTIES.put("delimited-identifiers", "true"); > EMF_PROPERTIES.put(PersistenceUnitProperties.NON_JTA_DATASOURCE, dataSource); > } > > public AbstractBaseTest(String name) { >- environment = new EnvironmentAdapter(); >+ environment = new ResourceLocalEnvironment(); > puName = name; > } > >@@ -87,10 +117,90 @@ > > } > >- final class EnvironmentAdapter implements JPAEnvironment { >+ final class ResourceLocalEnvironment implements JPAEnvironment { > > @Override > public void beginTransaction(EntityManager em) { >+ em.getTransaction().begin(); >+ } >+ >+ @Override >+ public void commitTransaction(EntityManager em) { >+ em.getTransaction().commit(); >+ } >+ >+ @Override >+ public void commitTransactionAndClear(EntityManager em) { >+ try { >+ commitTransaction(em); >+ } finally { >+ em.clear(); >+ } >+ } >+ >+ @Override >+ public EntityManagerFactory createNewEntityManagerFactory() throws NamingException { >+ AbstractBaseTest.closeEntityManagerFactory(puName); >+ return Persistence.createEntityManagerFactory(puName, EMF_PROPERTIES); >+ } >+ >+ @Override >+ public EntityManager getEntityManager() { >+ return getEntityManagerFactory().createEntityManager(); >+ // return AbstractBaseTest.createEntityManager(puName, >+ // EMF_PROPERTIES); >+ } >+ >+ @Override >+ public EntityManagerFactory getEntityManagerFactory() { >+ return AbstractBaseTest.getEntityManagerFactory(puName, EMF_PROPERTIES); >+ } >+ >+ @Override >+ public boolean isTransactionActive(EntityManager em) { >+ return em.getTransaction().isActive(); >+ } >+ >+ @Override >+ public boolean isTransactionMarkedForRollback(EntityManager em) { >+ return em.getTransaction().getRollbackOnly(); >+ } >+ >+ @Override >+ public void markTransactionForRollback(EntityManager em) { >+ throw new UnsupportedOperationException(); >+ } >+ >+ @Override >+ public void rollbackTransaction(EntityManager em) { >+ em.getTransaction().rollback(); >+ } >+ >+ @Override >+ public void rollbackTransactionAndClear(EntityManager em) { >+ try { >+ rollbackTransaction(em); >+ } finally { >+ em.clear(); >+ } >+ } >+ >+ @Override >+ public boolean usesExtendedPC() { >+ return true; >+ } >+ >+ @Override >+ public DataSource getDataSource() { >+ return AbstractBaseTest.this.getDataSource(); >+ } >+ >+ } >+ >+ final class JTATxScopedEnvironment implements JPAEnvironment { >+ >+ @Override >+ public void beginTransaction(EntityManager em) { > AbstractBaseTest.this.beginTransaction(em); > } > >@@ -110,18 +220,18 @@ > > @Override > public EntityManagerFactory createNewEntityManagerFactory() throws NamingException { >- JUnitTestCase.closeEntityManagerFactory(puName); >+ AbstractBaseTest.closeEntityManagerFactory(puName); > return Persistence.createEntityManagerFactory(puName, EMF_PROPERTIES); > } > > @Override > public EntityManager getEntityManager() { >- return JUnitTestCase.createEntityManager(puName, EMF_PROPERTIES); >+ return AbstractBaseTest.createEntityManager(puName, EMF_PROPERTIES); > } > > @Override > public EntityManagerFactory getEntityManagerFactory() { >- return JUnitTestCase.getEntityManagerFactory(puName, EMF_PROPERTIES); >+ return AbstractBaseTest.getEntityManagerFactory(puName, EMF_PROPERTIES); > } > > @Override >@@ -169,13 +279,14 @@ > return dataSource; > } > >- @Override > final public void closeEntityManager(EntityManager em) { > if (!em.isOpen()) { > return; > } > if (environment.isTransactionActive(em)/* >- * ||environment. isTransactionMarkedForRollback (em) >+ * ||environment. >+ * isTransactionMarkedForRollback >+ * (em) > */) { // FIXME discuss if tx is > // active if marked for > // rollback >@@ -255,8 +366,7 @@ > > } > >- public static final <T extends Serializable> T serializeDeserialize(T serializable) throws IOException, >- ClassNotFoundException { >+ public static final <T extends Serializable> T serializeDeserialize(T serializable) throws IOException, ClassNotFoundException { > ByteArrayOutputStream out = new ByteArrayOutputStream(); > ObjectOutputStream objectOutputStream = new ObjectOutputStream(out); > try { >@@ -273,12 +383,14 @@ > } > > /** >- * Checks whether the given throwable is of type java.lang.IllegalStateException, or otherwise if the throwable contains a >+ * Checks whether the given throwable is of type >+ * java.lang.IllegalStateException, or otherwise if the throwable contains a > * java.lang.IllegalStateException somewhere in the cause stack. > * > * @param e > * The throwable to check >- * @return <code>true</code> if the throwable is instance of or caused by java.lang.IllegalStateException >+ * @return <code>true</code> if the throwable is instance of or caused by >+ * java.lang.IllegalStateException > */ > protected final boolean checkForIllegalStateException(Throwable e) { > boolean contained = false; >@@ -293,12 +405,14 @@ > } > > /** >- * Checks whether the given throwable is of type java.sql.SQLException, or otherwise if the throwable contains a >- * java.sql.SQLException somewhere in the cause stack. >+ * Checks whether the given throwable is of type java.sql.SQLException, or >+ * otherwise if the throwable contains a java.sql.SQLException somewhere in >+ * the cause stack. > * > * @param e > * The throwable to check >- * @return <code>true</code> if the throwable is instance of or caused by java.sql.SQLException >+ * @return <code>true</code> if the throwable is instance of or caused by >+ * java.sql.SQLException > */ > protected final boolean checkForSQLException(Throwable e) { > boolean contained = false; >@@ -312,4 +426,147 @@ > return contained; > } > >+ /** >+ * Return if the transaction is active. This allows the same code to be used >+ * on the server where JTA is used. >+ */ >+ public boolean isTransactionActive(EntityManager entityManager) { >+ if (ServerInfoHolder.isOnServer()) { >+ return getServerPlatform().isTransactionActive(); >+ } else { >+ return entityManager.getTransaction().isActive(); >+ } >+ } >+ >+ /** >+ * Return if the transaction is roll back only. This allows the same code to >+ * be used on the server where JTA is used. >+ */ >+ public boolean getRollbackOnly(EntityManager entityManager) { >+ if (ServerInfoHolder.isOnServer()) { >+ return getServerPlatform().getRollbackOnly(); >+ } else { >+ return entityManager.getTransaction().getRollbackOnly(); >+ } >+ } >+ >+ /** >+ * Begin a transaction on the entity manager. This allows the same code to >+ * be used on the server where JTA is used. >+ */ >+ public void beginTransaction(EntityManager entityManager) { >+ if (ServerInfoHolder.isOnServer()) { >+ getServerPlatform().beginTransaction(); >+ } else { >+ entityManager.getTransaction().begin(); >+ } >+ } >+ >+ /** >+ * Commit a transaction on the entity manager. This allows the same code to >+ * be used on the server where JTA is used. >+ */ >+ public void commitTransaction(EntityManager entityManager) { >+ if (ServerInfoHolder.isOnServer()) { >+ getServerPlatform().commitTransaction(); >+ } else { >+ entityManager.getTransaction().commit(); >+ } >+ } >+ >+ /** >+ * Rollback a transaction on the entity manager. This allows the same code >+ * to be used on the server where JTA is used. >+ */ >+ public void rollbackTransaction(EntityManager entityManager) { >+ if (ServerInfoHolder.isOnServer()) { >+ getServerPlatform().rollbackTransaction(); >+ } else { >+ entityManager.getTransaction().rollback(); >+ } >+ } >+ >+ /** >+ * Return the server platform if running in JEE. >+ */ >+ public static ServerPlatform getServerPlatform() { >+ if (serverPlatform == null) { >+ serverPlatform = new JEEPlatform(); >+ } >+ return serverPlatform; >+ } >+ >+ /** >+ * Create a new entity manager for the "default" persistence unit. If in JEE >+ * this will create or return the active managed entity manager. >+ */ >+ public static EntityManager createEntityManager() { >+ if (ServerInfoHolder.isOnServer()) { >+ return getServerPlatform().getEntityManager("default"); >+ } else { >+ return getEntityManagerFactory().createEntityManager(); >+ } >+ } >+ >+ /** >+ * Create a new entity manager for the persistence unit using the >+ * properties. The properties will only be used the first time this entity >+ * manager is accessed. If in JEE this will create or return the active >+ * managed entity manager. >+ */ >+ public static EntityManager createEntityManager(String persistenceUnitName, Map<String, String> properties) { >+ if (ServerInfoHolder.isOnServer()) { >+ return getServerPlatform().getEntityManager(persistenceUnitName); >+ } else { >+ return getEntityManagerFactory(persistenceUnitName, properties).createEntityManager(); >+ } >+ } >+ >+ public static EntityManagerFactory getEntityManagerFactory(String persistenceUnitName) { >+ return getEntityManagerFactory(persistenceUnitName, JUnitTestCaseHelper.getDatabaseProperties()); >+ } >+ >+ public static EntityManagerFactory getEntityManagerFactory(String persistenceUnitName, Map<String, String> properties) { >+ if (ServerInfoHolder.isOnServer()) { >+ return getServerPlatform().getEntityManagerFactory(persistenceUnitName); >+ } else { >+ EntityManagerFactory emfNamedPersistenceUnit = (EntityManagerFactory) emfNamedPersistenceUnits.get(persistenceUnitName); >+ if (emfNamedPersistenceUnit == null) { >+ emfNamedPersistenceUnit = Persistence.createEntityManagerFactory(persistenceUnitName, properties); >+ emfNamedPersistenceUnits.put(persistenceUnitName, emfNamedPersistenceUnit); >+ } >+ return emfNamedPersistenceUnit; >+ } >+ } >+ >+ public static EntityManagerFactory getEntityManagerFactory() { >+ return getEntityManagerFactory("default"); >+ } >+ >+ public static void closeEntityManagerFactory() { >+ closeEntityManagerFactory("default"); >+ } >+ >+ public static void closeEntityManagerFactory(String persistenceUnitName) { >+ EntityManagerFactory emfNamedPersistenceUnit = (EntityManagerFactory) emfNamedPersistenceUnits.get(persistenceUnitName); >+ if (emfNamedPersistenceUnit != null) { >+ if (emfNamedPersistenceUnit.isOpen()) { >+ emfNamedPersistenceUnit.close(); >+ } >+ emfNamedPersistenceUnits.remove(persistenceUnitName); >+ } >+ } >+ >+ public static boolean seesJPA2() { >+ return seesJPA2; >+ } >+ >+ public static Map<String, String> getTestProperties() { >+ if (ServerInfoHolder.isOnServer()) { >+ return ServerInfoHolder.getTestProperties(); >+ } else { >+ return JUnitTestCaseHelper.getDatabaseProperties(); >+ } >+ >+ } > } >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/CollectNotificationsListener.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/CollectNotificationsListener.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/CollectNotificationsListener.java (revision 0) >@@ -0,0 +1,75 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.junit.runner.Description; >+import org.junit.runner.Result; >+import org.junit.runner.notification.Failure; >+import org.junit.runner.notification.RunListener; >+ >+/** >+ * Implementation of RunListener, which records serializable notifications so >+ * that they can be replayed on the can be replayed on the client. >+ */ >+final class CollectNotificationsListener extends RunListener { >+ private final List<Notification> notifications = new ArrayList<Notification>(); >+ >+ CollectNotificationsListener() { >+ } >+ >+ /** >+ * Get the list of notifications recorded. >+ * @return the list of notifications recorded >+ */ >+ public List<Notification> getNotifications() { >+ return notifications; >+ } >+ >+ @Override >+ public void testAssumptionFailure(Failure failure) { >+ notifications.add(new TestAssumptionFailed(failure)); >+ } >+ >+ @Override >+ public void testFailure(Failure failure) throws Exception { >+ notifications.add(new TestFailed(failure)); >+ } >+ >+ @Override >+ public void testFinished(Description description) throws Exception { >+ notifications.add(new TestFinished(description)); >+ } >+ >+ @Override >+ public void testIgnored(Description description) throws Exception { >+ notifications.add(new TestIgnored(description)); >+ } >+ >+ @Override >+ public void testRunFinished(Result result) throws Exception { >+ notifications.add(new TestRunFinished(result)); >+ } >+ >+ @Override >+ public void testRunStarted(Description description) throws Exception { >+ notifications.add(new TestRunStarted(description)); >+ } >+ >+ @Override >+ public void testStarted(Description description) throws Exception { >+ notifications.add(new TestStarted(description)); >+ } >+} >\ No newline at end of file >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/Notification.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/Notification.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/Notification.java (revision 0) >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import java.io.Serializable; >+ >+import org.junit.runner.notification.RunNotifier; >+ >+/** >+ * A recordable notification. >+ */ >+public interface Notification extends Serializable { >+ >+ /** >+ * Notify a run notifier of this notification. >+ * @param notifier >+ */ >+ public void notify(RunNotifier notifier); >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/SerializableDescription.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/SerializableDescription.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/SerializableDescription.java (revision 0) >@@ -0,0 +1,72 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import java.io.Serializable; >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+ >+import org.junit.runner.Description; >+ >+/** >+ * Serializable version of org.junit.runner.Description. >+ */ >+public class SerializableDescription implements Serializable { >+ >+ private static final long serialVersionUID = 1L; >+ private final String displayName; >+ private final List<SerializableDescription> children; >+ >+ private SerializableDescription(String theDisplayName, List<SerializableDescription> theChildren) { >+ displayName = theDisplayName; >+ children = theChildren; >+ } >+ >+ /** >+ * Create a SerializableDescription objects from an org.junit.runner.Description objects >+ * @param description the org.junit.runner.Description object to be converted >+ * @return the SerializableDescription object created from an org.junit.runner.Description object >+ */ >+ @SuppressWarnings("unchecked") >+ public static SerializableDescription create(Description description) { >+ final List<SerializableDescription> children; >+ if (description.getChildren() != null) { >+ children = new ArrayList<SerializableDescription>(); >+ for (Description child : description.getChildren()) { >+ children.add(create(child)); >+ } >+ } else { >+ children = Collections.EMPTY_LIST; >+ } >+ return new SerializableDescription(description.getDisplayName(), children); >+ >+ } >+ >+ /** >+ * Restore an org.junit.runner.Description from this SerializableDescription object >+ * @return the restored org.junit.runner.Description object >+ */ >+ public Description restore() { >+ Description restored = Description.createSuiteDescription(displayName); >+ >+ if (children != null) { >+ for (SerializableDescription child : children) { >+ restored.addChild(child.restore()); >+ } >+ } >+ >+ return restored; >+ } >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/SerializableFailure.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/SerializableFailure.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/SerializableFailure.java (revision 0) >@@ -0,0 +1,50 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import java.io.Serializable; >+ >+import org.junit.runner.notification.Failure; >+ >+/** >+ * Serializable version of org.junit.runner.notification.Failure. >+ */ >+public class SerializableFailure implements Serializable { >+ >+ private static final long serialVersionUID = 1L; >+ private final SerializableDescription description; >+ private final Throwable thrownException; >+ >+ private SerializableFailure(SerializableDescription theDescription, Throwable throwable) { >+ description = theDescription; >+ thrownException = throwable; >+ } >+ >+ /** >+ * Create a SerializableFailure object from an org.junit.runner.notification.Failure object. >+ * @param the failure object to be converted >+ * @return a SerializableFailure object converted from an org.junit.runner.notification.Failure object >+ */ >+ public static SerializableFailure create(Failure failure) { >+ return new SerializableFailure(SerializableDescription.create(failure.getDescription()),failure.getException()); >+ } >+ >+ /** >+ * Restore an org.junit.runner.notification.Failure object from this SerializableFailure object. >+ * @return the restored org.junit.runner.notification.Failure object >+ */ >+ public Failure restore() { >+ return new Failure(description.restore(), thrownException); >+ } >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/SerializableResult.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/SerializableResult.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/SerializableResult.java (revision 0) >@@ -0,0 +1,73 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import java.io.Serializable; >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+ >+import org.junit.runner.Result; >+import org.junit.runner.notification.Failure; >+ >+/** >+ * Serializable version of org.junit.runner.Result. >+ */ >+public class SerializableResult implements Serializable { >+ >+ private static final long serialVersionUID = 1L; >+ @SuppressWarnings("unused") >+ private final int count; >+ @SuppressWarnings("unused") >+ private final int ignoreCount; >+ @SuppressWarnings("unused") >+ private final List<SerializableFailure> failures; >+ @SuppressWarnings("unused") >+ private final long runTime; >+ >+ private SerializableResult(int cnt, int ign, List<SerializableFailure> fls, long rt) { >+ count = cnt; >+ ignoreCount = ign; >+ failures = fls; >+ runTime = rt; >+ } >+ >+ /** >+ * Create a SerializableResult object from an org.junit.runner.Result object. >+ * @param other the org.junit.runner.Result object to be converted >+ * @return the SerializableResult object created from an org.junit.runner.Result object >+ */ >+ @SuppressWarnings("unchecked") >+ public static SerializableResult create(Result other) { >+ final List<SerializableFailure> failures; >+ >+ if (other.getFailures() != null) { >+ failures = new ArrayList<SerializableFailure>(); >+ for(Failure failure : other.getFailures()) { >+ failures.add(SerializableFailure.create(failure)); >+ } >+ } else { >+ failures = Collections.EMPTY_LIST; >+ } >+ >+ return new SerializableResult(other.getFailureCount(), other.getIgnoreCount(), failures, other.getRunTime()); >+ >+ } >+ >+ public Result restore() { >+ return new Result(); // FIXME don't know how to restore the result >+ >+ } >+ >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/ServerTestRunner.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/ServerTestRunner.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/ServerTestRunner.java (revision 0) >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import java.util.List; >+import java.util.Map; >+ >+import javax.ejb.Remote; >+ >+/** >+ * Session bean used to redirect JUnit 4 test execution from client to server >+ */ >+@Remote >+public interface ServerTestRunner { >+ >+ /** >+ * Redirects test execution from client to server. >+ * @param className the name of test class to be executed >+ * @param dsName the JNID lookup name of the data source used by the test >+ * @param testProperties the test properties >+ * @return a list of notifications recorded during test execution >+ */ >+ public List<Notification> runTestClass(String className, String dsName, Map<String, String> testProperties); >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/ServerTestRunnerImpl.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/ServerTestRunnerImpl.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/ServerTestRunnerImpl.java (revision 0) >@@ -0,0 +1,52 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import java.util.List; >+import java.util.Map; >+ >+import javax.ejb.Stateless; >+import javax.ejb.TransactionManagement; >+import javax.ejb.TransactionManagementType; >+ >+import org.eclipse.persistence.testing.framework.wdf.ServerInfoHolder; >+import org.junit.runner.JUnitCore; >+ >+/** >+ * Implementation of the server test runner. >+ */ >+ >+@Stateless >+@TransactionManagement(TransactionManagementType.BEAN) >+public class ServerTestRunnerImpl implements ServerTestRunner { >+ >+ @Override >+ public List<Notification> runTestClass(String className, String dsName, Map<String, String> testProperties) { >+ >+ Class<?> clazz; >+ try { >+ ServerInfoHolder.setServerInfo(dsName, testProperties); >+ clazz = Class.forName(className); >+ } catch (ClassNotFoundException e) { >+ throw new RuntimeException(e); >+ } >+ >+ JUnitCore core = new JUnitCore(); >+ CollectNotificationsListener listener = new CollectNotificationsListener(); >+ core.addListener(listener); >+ core.run(clazz); >+ >+ return listener.getNotifications(); >+ } >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestAssumptionFailed.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestAssumptionFailed.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestAssumptionFailed.java (revision 0) >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import org.junit.runner.notification.Failure; >+import org.junit.runner.notification.RunNotifier; >+ >+/** >+ * A notification indicating that a test assumption failed. >+ */ >+public class TestAssumptionFailed implements Notification { >+ >+ private static final long serialVersionUID = 1L; >+ private final SerializableFailure failure; >+ >+ public TestAssumptionFailed(Failure aFailure) { >+ failure = SerializableFailure.create(aFailure); >+ } >+ >+ @Override >+ public void notify(RunNotifier notifier) { >+ notifier.fireTestAssumptionFailed(failure.restore()); >+ } >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestFailed.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestFailed.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestFailed.java (revision 0) >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import org.junit.runner.notification.Failure; >+import org.junit.runner.notification.RunNotifier; >+ >+/** >+ * A notification indicating that at test failed. >+ */ >+public class TestFailed implements Notification { >+ >+ private static final long serialVersionUID = 1L; >+ private final SerializableFailure failure; >+ >+ public TestFailed(Failure aFailure) { >+ failure = SerializableFailure.create(aFailure); >+ } >+ >+ @Override >+ public void notify(RunNotifier notifier) { >+ notifier.fireTestFailure(failure.restore()); >+ } >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestFinished.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestFinished.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestFinished.java (revision 0) >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import org.junit.runner.Description; >+import org.junit.runner.notification.RunNotifier; >+ >+/** >+ * A notification indicating that the execution of a test has finished. >+ */ >+public class TestFinished implements Notification { >+ >+ private static final long serialVersionUID = 1L; >+ private final SerializableDescription description; >+ >+ public TestFinished(Description aDescription) { >+ description = SerializableDescription.create(aDescription); >+ } >+ >+ @Override >+ public void notify(RunNotifier notifier) { >+ notifier.fireTestFinished(description.restore()); >+ } >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestIgnored.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestIgnored.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestIgnored.java (revision 0) >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import org.junit.runner.Description; >+import org.junit.runner.notification.RunNotifier; >+ >+/** >+ * A notification indicating that a test has been ignored or skipped. >+ */ >+public class TestIgnored implements Notification { >+ >+ private static final long serialVersionUID = 1L; >+ private final SerializableDescription description; >+ >+ public TestIgnored(Description aDescription) { >+ description = SerializableDescription.create(aDescription); >+ } >+ >+ @Override >+ public void notify(RunNotifier notifier) { >+ notifier.fireTestIgnored(description.restore()); >+ } >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestRunFinished.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestRunFinished.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestRunFinished.java (revision 0) >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import org.junit.runner.Result; >+import org.junit.runner.notification.RunNotifier; >+ >+/** >+ * A notification indicating that a test run has finished. >+ */ >+public class TestRunFinished implements Notification { >+ >+ private static final long serialVersionUID = 1L; >+ private final SerializableResult result; >+ >+ public TestRunFinished(Result aResult) { >+ result = SerializableResult.create(aResult); >+ } >+ >+ @Override >+ public void notify(RunNotifier notifier) { >+ notifier.fireTestRunFinished(result.restore()); >+ } >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestRunStarted.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestRunStarted.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestRunStarted.java (revision 0) >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import org.junit.runner.Description; >+import org.junit.runner.notification.RunNotifier; >+ >+/** >+ * A notification indicating that a tes run has started. >+ */ >+public class TestRunStarted implements Notification { >+ >+ private static final long serialVersionUID = 1L; >+ private final SerializableDescription description; >+ >+ public TestRunStarted(Description aDescription) { >+ description = SerializableDescription.create(aDescription); >+ } >+ >+ @Override >+ public void notify(RunNotifier notifier) { >+ notifier.fireTestRunStarted(description.restore()); >+ } >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestStarted.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestStarted.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/server/TestStarted.java (revision 0) >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf.server; >+ >+import org.junit.runner.Description; >+import org.junit.runner.notification.RunNotifier; >+ >+/** >+ * A notification indicating that the execution of a test has started. >+ */ >+public class TestStarted implements Notification { >+ >+ private static final long serialVersionUID = 1L; >+ private final SerializableDescription description; >+ >+ public TestStarted(Description aDescription) { >+ description = SerializableDescription.create(aDescription); >+ } >+ >+ @Override >+ public void notify(RunNotifier notifier) { >+ notifier.fireTestStarted(description.restore()); >+ } >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/ServerInfoHolder.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/ServerInfoHolder.java (revision 0) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/ServerInfoHolder.java (revision 0) >@@ -0,0 +1,70 @@ >+/******************************************************************************* >+ * Copyright (c) 2005, 2009 SAP. All rights reserved. >+ * 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. >+ * >+ * Contributors: >+ * SAP - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.persistence.testing.framework.wdf; >+ >+import java.util.Collections; >+import java.util.Map; >+ >+/** >+ * Static class to hold state shared between ServerTestRunner and tests >+ */ >+public class ServerInfoHolder { >+ >+ @SuppressWarnings("unchecked") >+ private static Map<String, String> testProperties = Collections.EMPTY_MAP; >+ private static String dataSourceName; >+ private static boolean isOnServer = false; >+ >+ /** >+ * Get the set of test properties >+ * @return the set of test properties >+ */ >+ public static synchronized Map<String, String> getTestProperties() { >+ return testProperties; >+ } >+ >+ >+ >+ // prevent instantiation >+ private ServerInfoHolder() { >+ >+ } >+ >+ /** >+ * @return if the test is running on a JEE server, or in JSE. >+ */ >+ public static boolean isOnServer() { >+ return isOnServer; >+ } >+ >+ >+ /** >+ * Get the JNDI lookup name of the data source used by the tests >+ * @return the JNDI lookup name of the data source used by the tests >+ */ >+ public synchronized static String getDataSourceName() { >+ return dataSourceName; >+ } >+ >+ /** >+ * set info needed to execute the tests on the server >+ * @param dsName the JNDI lookup name of the data source used by the tests >+ * @param properties the test properties >+ */ >+ public static synchronized void setServerInfo(String dsName, Map<String, String> properties) { >+ isOnServer = true; >+ dataSourceName = dsName; >+ testProperties = properties; >+ } >+ >+} >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/Skip.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/Skip.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/Skip.java (working copy) >@@ -28,4 +28,9 @@ > * The databases on which this test should be skipped. Default: skip on all databases > */ > Class<? extends DatabasePlatform>[] databases() default {}; >+ >+ /** >+ * Indicates if this test should be skipped on server. >+ */ >+ boolean server() default false; > } >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/SkipBugzillaTestRunner.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/SkipBugzillaTestRunner.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/framework/wdf/SkipBugzillaTestRunner.java (working copy) >@@ -15,11 +15,20 @@ > > import java.lang.annotation.Annotation; > import java.lang.reflect.Method; >+import java.util.List; > import java.util.Map; >+import java.util.Properties; > >+import javax.naming.Context; >+import javax.naming.InitialContext; >+import javax.naming.NamingException; >+import javax.rmi.PortableRemoteObject; >+ > import org.eclipse.persistence.config.PersistenceUnitProperties; > import org.eclipse.persistence.platform.database.DatabasePlatform; >-import org.eclipse.persistence.testing.framework.junit.JUnitTestCaseHelper; >+import org.eclipse.persistence.testing.framework.wdf.server.Notification; >+import org.eclipse.persistence.testing.framework.wdf.server.ServerTestRunner; >+import org.junit.Assert; > import org.junit.runner.Description; > import org.junit.runner.notification.RunNotifier; > import org.junit.runners.BlockJUnit4ClassRunner; >@@ -27,24 +36,88 @@ > > public class SkipBugzillaTestRunner extends BlockJUnit4ClassRunner { > >+ private static final String TEST_TO_BE_INVESTIGATED_RUN = "test.to-be-investigated.run"; >+ private static final String TEST_ISSUE_RUN = "test.issue.run"; >+ private static final String TEST_BUGZILLA_RUN = "test.bugzilla.run"; >+ >+ >+ @Override >+ public void run(RunNotifier notifier) { >+ if (Boolean.valueOf(System.getProperty("servertest"))) { >+ runOnServer(notifier); >+ } else { >+ super.run(notifier); >+ } >+ } >+ >+ /** >+ * Delegates test execution to the server. On the server, JUnit will be >+ * invoked to run the tests with a special run listener, which collects >+ * the notifications (events). On the client, the recorded notifications will be >+ * replayed on the run notifier passed to this message. >+ * @param notifier the run notifier to replay the notifications recorded on the server >+ */ >+ private void runOnServer(RunNotifier notifier) { >+ Properties properties = new Properties(); >+ String url = getMandatorySystemProperty("server.url"); >+ properties.put("java.naming.provider.url", url); >+ Context context; >+ try { >+ context = new InitialContext(properties); >+ String testrunner = getMandatorySystemProperty("server.testrunner.wdf"); >+ String dataSourceName = getMandatorySystemProperty("datasource.name"); >+ >+ Object object = context.lookup(testrunner); >+ ServerTestRunner runner = (ServerTestRunner) PortableRemoteObject.narrow(object, ServerTestRunner.class); >+ String testClassName = getTestClass().getJavaClass().getName(); >+ List<Notification> notifications = runner.runTestClass(testClassName, dataSourceName, testProperties); >+ >+ for (Notification notification : notifications) { >+ notification.notify(notifier); >+ } >+ } catch (NamingException e) { >+ throw new RuntimeException(e); >+ } >+ } >+ >+ private String getMandatorySystemProperty(final String propertyName) { >+ String url = System.getProperty(propertyName); >+ if (url == null) { >+ Assert.fail("System property '" + propertyName + "' must be set."); >+ } >+ return url; >+ } >+ > final long bugid; > final long issueid; > final boolean runAllBugzilla; > final boolean runAllIssues; > final boolean runAllUnknown; > final Class<? extends DatabasePlatform> databasePlatformClass; >+ private final Map<String, String> testProperties; > >+ > @SuppressWarnings("unchecked") > public SkipBugzillaTestRunner(Class<?> klass) throws Throwable { > super(klass); > >- Map<String, String> properties = JUnitTestCaseHelper.getDatabaseProperties(); >+ testProperties = AbstractBaseTest.getTestProperties(); >+ >+ >+ addProperty(TEST_BUGZILLA_RUN); >+ addProperty(TEST_ISSUE_RUN); >+ addProperty(TEST_TO_BE_INVESTIGATED_RUN); > >- String databasePlatformClassName = properties.get(PersistenceUnitProperties.TARGET_DATABASE); >+ String databasePlatformClassName = testProperties.get(PersistenceUnitProperties.TARGET_DATABASE); >+ > >+ if (databasePlatformClassName != null) { > databasePlatformClass = (Class<? extends DatabasePlatform>) Class.forName(databasePlatformClassName); >+ } else { >+ databasePlatformClass = null; // FIXME >+ } > >- String testBugzillaRun = (String) properties.get("test.bugzilla.run"); >+ String testBugzillaRun = (String) testProperties.get(TEST_BUGZILLA_RUN); > if ("all".equals(testBugzillaRun)) { > runAllBugzilla = true; > bugid = -1; >@@ -57,7 +130,7 @@ > } > } > >- String testIssueRun = (String) properties.get("test.issue.run"); >+ String testIssueRun = (String) testProperties.get(TEST_ISSUE_RUN); > if ("all".equals(testIssueRun)) { > runAllIssues = true; > issueid = -1; >@@ -70,15 +143,23 @@ > } > } > >- String testToBeInvestigatedRun = (String) properties.get("test.to-be-investigated.run"); >+ String testToBeInvestigatedRun = (String) testProperties.get(TEST_TO_BE_INVESTIGATED_RUN); > if ("all".equals(testToBeInvestigatedRun)) { > runAllUnknown = true; > } else { > runAllUnknown = false; > } >+ > > } > >+ private void addProperty(final String name) { >+ String value = System.getProperty(name); >+ if(value != null) { >+ testProperties.put(name, value); >+ } >+ } >+ > @Override > protected void runChild(FrameworkMethod method, RunNotifier notifier) { > try { >@@ -115,10 +196,12 @@ > throw new SkipException(); > } > >- for (Class<? extends DatabasePlatform> clazz : databases) { >- if (clazz.isAssignableFrom(databasePlatformClass)) { >- // the current database platform is not supported >- throw new SkipException(); >+ if (databasePlatformClass != null) { >+ for (Class<? extends DatabasePlatform> clazz : databases) { >+ if (clazz.isAssignableFrom(databasePlatformClass)) { >+ // the current database platform is not supported >+ throw new SkipException(); >+ } > } > } > >@@ -148,6 +231,11 @@ > > @Override > public boolean runThis(Skip skip) { >+ >+ if(skip.server()) { >+ return !ServerInfoHolder.isOnServer(); >+ } >+ > return false; > } > >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/entitymanager/TestEntityManagerFactory.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/entitymanager/TestEntityManagerFactory.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/entitymanager/TestEntityManagerFactory.java (working copy) >@@ -23,6 +23,7 @@ > import org.eclipse.persistence.testing.tests.wdf.jpa1.JPA1Base; > import org.eclipse.persistence.testing.framework.wdf.AbstractBaseTest; > import org.eclipse.persistence.testing.framework.wdf.JPAEnvironment; >+import org.eclipse.persistence.testing.framework.wdf.Skip; > import org.eclipse.persistence.testing.framework.wdf.ToBeInvestigated; > import org.eclipse.persistence.testing.models.wdf.jpa1.employee.Department; > >@@ -38,6 +39,7 @@ > } > > @Test() >+ @Skip(server=true) > public void testEntityManagerFactoryClose() throws NamingException { > final boolean closingEmfThrowsException = AbstractBaseTest.isInsideEngine(); > final JPAEnvironment env = getEnvironment(); >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/entitymanager/TestRemove.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/entitymanager/TestRemove.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/entitymanager/TestRemove.java (working copy) >@@ -375,7 +375,6 @@ > Department dep = new Department(40, "dep40"); > try { > em.remove(dep); >- flop("exception not thrown as expected"); > } catch (TransactionRequiredException e) { > // $JL-EXC$ expected behavior > } finally { >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/lock/TestOptimistic.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/lock/TestOptimistic.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/lock/TestOptimistic.java (working copy) >@@ -242,8 +242,8 @@ > caughtException = true; > } finally { > closeEntityManager(em); >- verify(caughtException, "PersistenceException not thrown for versionModification"); > } >+ verify(caughtException, "PersistenceException not thrown for versionModification"); > } > > @Test >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/query/TestSimpleQuery.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/query/TestSimpleQuery.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/query/TestSimpleQuery.java (working copy) >@@ -558,23 +558,35 @@ > closeEntityManager(em); > } > } >+ >+ private static boolean hasGetmaxRowsMethod() { >+ try { >+ return Query.class.getMethod("getMaxResults") != null; >+ } catch (NoSuchMethodException e) { >+ return false; >+ } >+ } > >- private void verifyRowCount(Query query, int maxRows, int startPos, int expected) { >+ private void verifyRowCount(Query query, int maxRows, int startPos, int expected) throws SecurityException, NoSuchMethodException { > query.setMaxResults(maxRows); > query.setFirstResult(startPos); > >- assertEquals(query.getMaxResults(), maxRows); >- assertEquals(query.getFirstResult(), startPos); >+ if (hasGetmaxRowsMethod()) { >+ assertEquals(query.getMaxResults(), maxRows); >+ assertEquals(query.getFirstResult(), startPos); >+ } > > int count = query.getResultList().size(); > verify(count == expected, "wrong row count: " + count); >- >- assertEquals(query.getMaxResults(), maxRows); >- assertEquals(query.getFirstResult(), startPos); >+ >+ if (hasGetmaxRowsMethod()) { >+ assertEquals(query.getMaxResults(), maxRows); >+ assertEquals(query.getFirstResult(), startPos); >+ } > } > > @Test >- public void testMaxResult() throws SQLException { >+ public void testMaxResult() throws SQLException, SecurityException, NoSuchMethodException { > clearAllTables(); > JPAEnvironment env = getEnvironment(); > EntityManager em = env.getEntityManager(); >@@ -601,7 +613,7 @@ > } > > @Test >- public void testMaxResultUnlimited() throws SQLException { >+ public void testMaxResultUnlimited() throws SQLException, SecurityException, NoSuchMethodException { > clearAllTables(); > JPAEnvironment env = getEnvironment(); > EntityManager em = env.getEntityManager(); >@@ -623,6 +635,9 @@ > > @Test > public void testPagingDefaults() throws SQLException { >+ if (!hasGetmaxRowsMethod()) { >+ return; >+ } > JPAEnvironment env = getEnvironment(); > EntityManager em = env.getEntityManager(); > try { >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/relation/TestBidirectionalManyToMany.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/relation/TestBidirectionalManyToMany.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/relation/TestBidirectionalManyToMany.java (working copy) >@@ -425,6 +425,33 @@ > } > > @Test >+ public void testCopyProjectsToExistingTouching() throws SQLException { >+ // copy all projects from hans to a new employee with out actually touching them >+ JPAEnvironment env = getEnvironment(); >+ EntityManager em = env.getEntityManager(); >+ try { >+ env.beginTransaction(em); >+ Employee hans = em.find(Employee.class, HANS_ID); >+ Employee fred = em.find(Employee.class, FRED_ID); >+ hans.getProjects().size(); >+ fred.setProjects(hans.getProjects()); >+ env.commitTransactionAndClear(em); >+ Set<Pair> expected = new HashSet<Pair>(SEED_SET); >+ expected.removeAll(FRED_SET); >+ for (Pair pair : HANS_SET) { >+ expected.add(new Pair(FRED_ID_VALUE, pair.getProjectId())); >+ } >+ checkJoinTable(expected); >+ env.beginTransaction(em); >+ fred = em.find(Employee.class, FRED_ID); >+ verify(fred.getProjects().size() == HANS_SET.size(), "Paul has wrong number of projects"); >+ env.rollbackTransactionAndClear(em); >+ } finally { >+ closeEntityManager(em); >+ } >+ } >+ >+ @Test > @Issue(issueid = 10) > public void testGuidCollection() throws SQLException { > JPAEnvironment env = getEnvironment(); >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/simple/BufferReadTest.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/simple/BufferReadTest.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa1/simple/BufferReadTest.java (working copy) >@@ -312,7 +312,6 @@ > public void run() { > try { > ResultSet rs = preparedStatement.executeQuery(); >- connection.commit(); > try { > rs.next(); > new Department(rs.getInt(1), rs.getString(2)); >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa2/embeddable/TestEmbeddingWithMixedAccess.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa2/embeddable/TestEmbeddingWithMixedAccess.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa2/embeddable/TestEmbeddingWithMixedAccess.java (working copy) >@@ -16,6 +16,7 @@ > import javax.persistence.EntityManager; > > import org.eclipse.persistence.testing.framework.wdf.JPAEnvironment; >+import org.eclipse.persistence.testing.framework.wdf.Skip; > import org.eclipse.persistence.testing.models.wdf.jpa2.embedded.EmbeddedFieldAccess; > import org.eclipse.persistence.testing.models.wdf.jpa2.embedded.EmbeddedPropertyAccess; > import org.eclipse.persistence.testing.models.wdf.jpa2.embedded.EmbeddingFieldAccess; >@@ -25,6 +26,7 @@ > public class TestEmbeddingWithMixedAccess extends JPA2Base { > > @Test >+ @Skip(server=true) > public void testFieldAccess() { > JPAEnvironment env = getEnvironment(); > EntityManager em = env.getEntityManager(); >@@ -45,6 +47,7 @@ > } > > @Test >+ @Skip(server=true) > public void testPropertyAccess() { > JPAEnvironment env = getEnvironment(); > EntityManager em = env.getEntityManager(); >Index: jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa2/embeddable/TestNestedEmbeddables.java >=================================================================== >--- jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa2/embeddable/TestNestedEmbeddables.java (revision 6940) >+++ jpa/eclipselink.jpa.wdf.test/src/org/eclipse/persistence/testing/tests/wdf/jpa2/embeddable/TestNestedEmbeddables.java (working copy) >@@ -23,6 +23,7 @@ > import javax.persistence.Query; > > import org.eclipse.persistence.testing.framework.wdf.JPAEnvironment; >+import org.eclipse.persistence.testing.framework.wdf.Skip; > import org.eclipse.persistence.testing.models.wdf.jpa2.employee.Address; > import org.eclipse.persistence.testing.models.wdf.jpa2.employee.ContactInfo; > import org.eclipse.persistence.testing.models.wdf.jpa2.employee.Employee; >@@ -43,6 +44,7 @@ > private static final String ORANGE = "Orange"; > > @Test >+ @Skip(server=true) > public void testNonNested() { > JPAEnvironment env = getEnvironment(); > EntityManager em = env.getEntityManager(); >@@ -62,6 +64,7 @@ > } > > @Test >+ @Skip(server=true) > public void testNested() { > JPAEnvironment env = getEnvironment(); > EntityManager em = env.getEntityManager(); >@@ -115,6 +118,7 @@ > } > > @Test >+ @Skip(server=true) > public void testNestedOuterNull() { > JPAEnvironment env = getEnvironment(); > EntityManager em = env.getEntityManager(); >@@ -148,6 +152,7 @@ > } > > @Test >+ @Skip(server=true) > public void testNestedInnerNull() { > JPAEnvironment env = getEnvironment(); > EntityManager em = env.getEntityManager(); >@@ -184,6 +189,7 @@ > } > > @Test >+ @Skip(server=true) > public void testNestedQuery() { > JPAEnvironment env = getEnvironment(); > EntityManager em = env.getEntityManager();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 301295
:
163501
|
163506
|
163632
| 164357 |
165106