[nobug] fix failing testMappedSuperclassWeaving test - server side
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
diff --git a/jpa/eclipselink.jpa.test/antbuild.xml b/jpa/eclipselink.jpa.test/antbuild.xml
index 8e87de1..05a559f 100644
--- a/jpa/eclipselink.jpa.test/antbuild.xml
+++ b/jpa/eclipselink.jpa.test/antbuild.xml
@@ -290,6 +290,9 @@
<condition property="SERVER.TESTRUNNER5" value="${MODEL_NAME}/${MODEL_NAME}_ejb/${server.testrunner5}">
<isset property="is.jboss"/>
</condition>
+ <condition property="SERVER.TESTRUNNER6" value="${MODEL_NAME}/${MODEL_NAME}_ejb/${server.testrunner6}">
+ <isset property="is.jboss"/>
+ </condition>
<property name="SERVER.URL" value="${server.url}${MODEL_NAME}"/>
<property name="SERVER.TESTRUNNER" value="${server.testrunner}"/>
<property name="SERVER.TESTRUNNER1" value="${server.testrunner1}"/>
@@ -297,6 +300,7 @@
<property name="SERVER.TESTRUNNER3" value="${server.testrunner3}"/>
<property name="SERVER.TESTRUNNER4" value="${server.testrunner4}"/>
<property name="SERVER.TESTRUNNER5" value="${server.testrunner5}"/>
+ <property name="SERVER.TESTRUNNER6" value="${server.testrunner6}"/>
<condition property="DS_NAME" value="java:/EclipseLinkDS">
<isset property="is.jboss"/>
@@ -2954,7 +2958,8 @@
TestRunner2Bean*.java
TestRunner3Bean*.java
TestRunner4Bean*.java
- TestRunner5Bean*.java"/>
+ TestRunner5Bean*.java
+ TestRunner6Bean*.java"/>
</delete>
</target>
@@ -3809,6 +3814,7 @@
<attribute name="runner3"/>
<attribute name="runner4"/>
<attribute name="runner5"/>
+ <attribute name="runner6"/>
<sequential>
<property name="server.lib.full" location="@{dir.lib}"/>
<path id="run.path">
@@ -3832,6 +3838,7 @@
<echo message=" * SERVER.TESTRUNNER3 = @{runner3}"/>
<echo message=" * SERVER.TESTRUNNER4 = @{runner4}"/>
<echo message=" * SERVER.TESTRUNNER5 = @{runner5}"/>
+ <echo message=" * SERVER.TESTRUNNER6 = @{runner6}"/>
<echo message=" * run.metadata.cache.test.suite = ${run.metadata.cache.test.suite}"/>
<echo message=" * run.path = ${run.path.message}"/>
<echo message=" * run.dir = ${run.dir}"/>
@@ -3850,6 +3857,7 @@
<sysproperty key="server.testrunner3" value="@{runner3}"/>
<sysproperty key="server.testrunner4" value="@{runner4}"/>
<sysproperty key="server.testrunner5" value="@{runner5}"/>
+ <sysproperty key="server.testrunner6" value="@{runner6}"/>
<sysproperty key="server.run" value="TRUE"/>
<sysproperty key="com.ibm.SSL.ConfigURL" value="${com.ibm.SSL.ConfigURL}"/>
<sysproperty key="com.ibm.CORBA.ConfigURL" value="${com.ibm.CORBA.ConfigURL}"/>
@@ -3885,6 +3893,7 @@
runner3="${SERVER.TESTRUNNER3}"
runner4="${SERVER.TESTRUNNER4}"
runner5="${SERVER.TESTRUNNER5}"
+ runner6="${SERVER.TESTRUNNER6}"
/>
</target>
diff --git a/jpa/eclipselink.jpa.test/glassfish.properties b/jpa/eclipselink.jpa.test/glassfish.properties
index 6811616..78e1ca1 100644
--- a/jpa/eclipselink.jpa.test/glassfish.properties
+++ b/jpa/eclipselink.jpa.test/glassfish.properties
@@ -65,6 +65,7 @@
server.testrunner3=TestRunner3#org.eclipse.persistence.testing.framework.server.TestRunner3
server.testrunner4=TestRunner4#org.eclipse.persistence.testing.framework.server.TestRunner4
server.testrunner5=TestRunner5#org.eclipse.persistence.testing.framework.server.TestRunner5
+server.testrunner6=TestRunner6#org.eclipse.persistence.testing.framework.server.TestRunner6
server.lib=${install.dir}/glassfish/lib
server.depend=appserv-rt.jar, javaee.jar
server.platform=Glassfish
diff --git a/jpa/eclipselink.jpa.test/jboss.properties b/jpa/eclipselink.jpa.test/jboss.properties
index 77424ca..741d8b2 100644
--- a/jpa/eclipselink.jpa.test/jboss.properties
+++ b/jpa/eclipselink.jpa.test/jboss.properties
@@ -27,6 +27,7 @@
server.testrunner3=TestRunner3/remote-org.eclipse.persistence.testing.framework.server.TestRunner3
server.testrunner4=TestRunner4/remote-org.eclipse.persistence.testing.framework.server.TestRunner4
server.testrunner5=TestRunner5/remote-org.eclipse.persistence.testing.framework.server.TestRunner5
+server.testrunner6=TestRunner6/remote-org.eclipse.persistence.testing.framework.server.TestRunner6
server.testrunner.wdf=ServerTestRunner/remote-org.eclipse.persistence.testing.framework.wdf.server.ServerTestRunner
persistence10.jar=${jboss.home}/common/lib/ejb3-persistence.jar
diff --git a/jpa/eclipselink.jpa.test/resource/eclipselink-jpa21-model/persistence.xml b/jpa/eclipselink.jpa.test/resource/eclipselink-jpa21-model/persistence.xml
index 7057013..de12e0c 100644
--- a/jpa/eclipselink.jpa.test/resource/eclipselink-jpa21-model/persistence.xml
+++ b/jpa/eclipselink.jpa.test/resource/eclipselink-jpa21-model/persistence.xml
@@ -171,8 +171,7 @@
<!-- A test model for bug #466271. -->
<persistence-unit name="pu-with-mappedsuperclass" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
- <shared-cache-mode>NONE</shared-cache-mode>
- <class>org.eclipse.persistence.testing.models.jpa21.advanced.Athlete</class>
+ <class>org.eclipse.persistence.testing.models.jpa21.advanced.WovenMS</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.weaving" value="true" />
diff --git a/jpa/eclipselink.jpa.test/resource/eclipselink-jpa21-model/server/persistence.xml b/jpa/eclipselink.jpa.test/resource/eclipselink-jpa21-model/server/persistence.xml
index 190ad8e..f36593b 100644
--- a/jpa/eclipselink.jpa.test/resource/eclipselink-jpa21-model/server/persistence.xml
+++ b/jpa/eclipselink.jpa.test/resource/eclipselink-jpa21-model/server/persistence.xml
@@ -162,4 +162,17 @@
<property name="eclipselink.weaving" value="@server-weaving@"/>
</properties>
</persistence-unit>
+ <!-- A test model for bug #466271. -->
+ <persistence-unit name="pu-with-mappedsuperclass" transaction-type="@transaction-type@">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <@datasource-type@>@data-source-name@</@datasource-type@>
+ <class>org.eclipse.persistence.testing.models.jpa21.advanced.WovenMS</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ <properties>
+ <property name="eclipselink.target-server" value="@server-platform@"/>
+ <property name="eclipselink.target-database" value="@database-platform@"/>
+ <property name="eclipselink.weaving" value="true" />
+ <property name="eclipselink.ddl-generation" value="none" />
+ </properties>
+ </persistence-unit>
</persistence>
diff --git a/jpa/eclipselink.jpa.test/resource/server/TestRunner6Bean.java b/jpa/eclipselink.jpa.test/resource/server/TestRunner6Bean.java
new file mode 100644
index 0000000..7479d24
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/resource/server/TestRunner6Bean.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Oracle and/or its affiliates. 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:
+ * Oracle - initial API and implementation from Oracle TopLink
+ ******************************************************************************/
+ package org.eclipse.persistence.testing.framework.server;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Properties;
+
+import javax.ejb.EJBException;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+
+import junit.framework.TestCase;
+
+import org.eclipse.persistence.testing.framework.junit.JUnitTestCase;
+
+/**
+ * Server side JUnit test invocation implemented as a stateless session bean.
+ *
+ * @author mschinca
+ */
+@Stateless(name="TestRunner6", mappedName="TestRunner6")
+@Remote(TestRunner6.class)
+@TransactionManagement(TransactionManagementType.BEAN)
+public class TestRunner6Bean implements TestRunner6 {
+
+ /** The entity manager for the test is injected and passed to the test server platform. */
+ @PersistenceContext(unitName="pu-with-mappedsuperclass")
+ private EntityManager entityManager;
+
+ /** The entity manager factory for the test is injected and passed to the test server platform. */
+ @PersistenceUnit(unitName="pu-with-mappedsuperclass")
+ private EntityManagerFactory entityManagerFactory;
+
+ /**
+ * Execute a test case method. The test class is loaded dynamically and
+ * must therefore be visible to the TestRunnerBean classloader.
+ */
+ public Throwable runTest(String className, String test, Properties props) {
+ // load the test class and create an instance
+ TestCase testInstance = null;
+ try {
+ Class testClass = getClass().getClassLoader().loadClass(className);
+ Constructor c = testClass.getConstructor(new Class[] { String.class });
+ testInstance = (TestCase) c.newInstance(new Object[] { test });
+ } catch (ClassNotFoundException e) {
+ throw new EJBException(e);
+ } catch (NoSuchMethodException e) {
+ throw new EJBException(e);
+ } catch (InstantiationException e) {
+ throw new EJBException(e);
+ } catch (IllegalAccessException e) {
+ throw new EJBException(e);
+ } catch (InvocationTargetException e) {
+ throw new EJBException(e);
+ }
+
+ // if any properties were passed in, set them into
+ // the server's VM
+ if (props != null) {
+ System.getProperties().putAll(props);
+ }
+
+ // execute the bare test case
+ Throwable result = null;
+ try {
+ if (testInstance instanceof JUnitTestCase) {
+ JUnitTestCase jpaTest = (JUnitTestCase)testInstance;
+ JEEPlatform.entityManager = this.entityManager;
+ JEEPlatform.entityManagerFactory = this.entityManagerFactory;
+ jpaTest.runBareServer();
+ } else {
+ testInstance.runBare();
+ }
+ } catch (Throwable t) {
+ result = t;
+ }
+ return result;
+ }
+
+}
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/framework/server/TestRunner6.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/framework/server/TestRunner6.java
new file mode 100644
index 0000000..1d0bc55
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/framework/server/TestRunner6.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Oracle and/or its affiliates. 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:
+ * Oracle - initial API and implementation from Oracle TopLink
+ ******************************************************************************/
+ package org.eclipse.persistence.testing.framework.server;
+
+import java.util.Properties;
+
+/**
+ * Remote business interface for TestRunner session bean.
+ *
+ * @author mschinca
+ */
+public interface TestRunner6 {
+ public Throwable runTest(String className, String test, Properties props);
+}
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/WovenMS.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/WovenMS.java
new file mode 100644
index 0000000..c81d5a7
--- /dev/null
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/WovenMS.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Oracle and/or its affiliates. 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:
+ * Oracle - initial API and implementation from Oracle TopLink
+ ******************************************************************************/
+package org.eclipse.persistence.testing.models.jpa21.advanced;
+
+import javax.persistence.Column;
+import javax.persistence.MappedSuperclass;
+
+@MappedSuperclass
+public class WovenMS {
+
+ protected Integer age;
+
+ @Column(name="P1")
+ protected String firstName;
+
+ @Column(name="P2")
+ protected String lastName;
+
+ public Integer getAge() {
+ return age;
+ }
+
+ public void setAge(Integer age) {
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+}
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa21/advanced/WeaverTestSuite.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa21/advanced/WeaverTestSuite.java
index 82c28fd..038c5c0 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa21/advanced/WeaverTestSuite.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa21/advanced/WeaverTestSuite.java
@@ -1,3 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2017 Oracle and/or its affiliates. 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:
+ * Lukas - Initial implementation
+ ******************************************************************************/
package org.eclipse.persistence.testing.tests.jpa21.advanced;
import java.util.Arrays;
@@ -7,7 +19,7 @@
import org.eclipse.persistence.internal.descriptors.PersistenceEntity;
import org.eclipse.persistence.testing.framework.junit.JUnitTestCase;
-import org.eclipse.persistence.testing.models.jpa21.advanced.Athlete;
+import org.eclipse.persistence.testing.models.jpa21.advanced.WovenMS;
import org.junit.Assert;
import junit.framework.Test;
@@ -17,6 +29,7 @@
public WeaverTestSuite(String name) {
super(name);
+ setPuName("pu-with-mappedsuperclass");
}
@Override
@@ -37,8 +50,8 @@
//bug #466271 - @MappedSuperclass with no implementations should be woven
public void testMappedSuperclassWeaving() {
EntityManagerFactory emf = getEntityManagerFactory();
- ManagedType<Athlete> managedType = emf.getMetamodel().managedType(Athlete.class);
- Class<Athlete> javaClass = emf.getMetamodel().managedType(Athlete.class).getJavaType();
+ ManagedType<WovenMS> managedType = emf.getMetamodel().managedType(WovenMS.class);
+ Class<WovenMS> javaClass = emf.getMetamodel().managedType(WovenMS.class).getJavaType();
Assert.assertTrue(Arrays.asList(javaClass.getInterfaces()).contains(PersistenceEntity.class));
}
}
diff --git a/jpa/eclipselink.jpa.test/weblogic.properties b/jpa/eclipselink.jpa.test/weblogic.properties
index 8b1fbd4..0deeca8 100644
--- a/jpa/eclipselink.jpa.test/weblogic.properties
+++ b/jpa/eclipselink.jpa.test/weblogic.properties
@@ -52,6 +52,7 @@
server.testrunner3=TestRunner3#org.eclipse.persistence.testing.framework.server.TestRunner3
server.testrunner4=TestRunner4#org.eclipse.persistence.testing.framework.server.TestRunner4
server.testrunner5=TestRunner5#org.eclipse.persistence.testing.framework.server.TestRunner5
+server.testrunner6=TestRunner6#org.eclipse.persistence.testing.framework.server.TestRunner6
server.depend=weblogic.jar,weblogic_sp.jar
server.platform=weblogic
server.platform.class=weblogic-10-platform
diff --git a/jpa/eclipselink.jpa.test/websphere.properties b/jpa/eclipselink.jpa.test/websphere.properties
index 7688d14..9c4d4fa 100644
--- a/jpa/eclipselink.jpa.test/websphere.properties
+++ b/jpa/eclipselink.jpa.test/websphere.properties
@@ -12,6 +12,7 @@
server.testrunner3=org.eclipse.persistence.testing.framework.server.TestRunner3
server.testrunner4=org.eclipse.persistence.testing.framework.server.TestRunner4
server.testrunner5=org.eclipse.persistence.testing.framework.server.TestRunner5
+server.testrunner6=org.eclipse.persistence.testing.framework.server.TestRunner6
server.lib=${was.home}/runtimes
server.factory=com.ibm.websphere.naming.WsnInitialContextFactory
server.persistence20.lib=${was.home}/feature_packs/jpa/plugins
diff --git a/jpa/eclipselink.jpa.test/wildfly.properties b/jpa/eclipselink.jpa.test/wildfly.properties
index 2b3c598..6cf0e59 100644
--- a/jpa/eclipselink.jpa.test/wildfly.properties
+++ b/jpa/eclipselink.jpa.test/wildfly.properties
@@ -23,6 +23,7 @@
server.testrunner3=TestRunner3!org.eclipse.persistence.testing.framework.server.TestRunner3
server.testrunner4=TestRunner4!org.eclipse.persistence.testing.framework.server.TestRunner4
server.testrunner5=TestRunner5!org.eclipse.persistence.testing.framework.server.TestRunner5
+server.testrunner6=TestRunner6!org.eclipse.persistence.testing.framework.server.TestRunner6
server.testrunner.wdf=ServerTestRunner/remote-org.eclipse.persistence.testing.framework.wdf.server.ServerTestRunner
persistence10.jar=${jboss.home}/common/lib/ejb3-persistence.jar