Index: jpa/eclipselink.jpa.test/resource/server/ejb-jar.xml
===================================================================
--- jpa/eclipselink.jpa.test/resource/server/ejb-jar.xml (revision 5579)
+++ jpa/eclipselink.jpa.test/resource/server/ejb-jar.xml (working copy)
@@ -8,11 +8,11 @@
TestRunner
- persistence/entity-manager
+ persistence/default/entity-manager
%%default%%
- persistence/factory
+ persistence/default/factory
%%default%%
Index: jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/framework/server/JEEPlatform.java
===================================================================
--- jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/framework/server/JEEPlatform.java (revision 5579)
+++ jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/framework/server/JEEPlatform.java (working copy)
@@ -33,6 +33,9 @@
/** The entity manager factory for the test is injected and passed to the test server platform. */
public static EntityManagerFactory entityManagerFactory;
+ /** The variable for getting entity manager by jndi lookup, set it to true in test.properties if you want jndi lookup */
+ public static final String EJB_LOOKUP = "ejb.lookup";
+
/**
* Nothing required in JEE.
*/
@@ -152,30 +155,34 @@
* Return the managed EntityManager for the persistence unit.
*/
public EntityManager getEntityManager(String persistenceUnit) {
- if (entityManager != null) {
+ String property = System.getProperty(EJB_LOOKUP);
+ if (property == null || !property.toUpperCase().equals("TRUE")){
return entityManager;
+ } else {
+ String contextName = "java:comp/env/persistence/" + persistenceUnit + "/entity-manager";
+ try {
+ return (EntityManager)new InitialContext().lookup(contextName);
+ } catch (NamingException exception) {
+ throw new RuntimeException(exception);
+ }
}
- String contextName = "java:comp/env/persistence/" + persistenceUnit + "/entity-manager";
- try {
- return (EntityManager)new InitialContext().lookup(contextName);
- } catch (NamingException exception) {
- throw new RuntimeException(exception);
- }
}
/**
* Return the managed EntityManagerFactory for the persistence unit.
*/
public EntityManagerFactory getEntityManagerFactory(String persistenceUnit) {
- if (entityManagerFactory != null) {
+ String property = System.getProperty(EJB_LOOKUP);
+ if (property == null || !property.toUpperCase().equals("TRUE")){
return entityManagerFactory;
+ } else{
+ String contextName = "java:comp/env/persistence/" + persistenceUnit + "/factory";
+ try {
+ return (EntityManagerFactory)new InitialContext().lookup(contextName);
+ } catch (NamingException exception) {
+ throw new RuntimeException(exception);
+ }
}
- String contextName = "java:comp/env/persistence/" + persistenceUnit + "/factory";
- try {
- return (EntityManagerFactory)new InitialContext().lookup(contextName);
- } catch (NamingException exception) {
- throw new RuntimeException(exception);
- }
}
}
Index: jpa/eclipselink.jpa.test/test.properties
===================================================================
--- jpa/eclipselink.jpa.test/test.properties (revision 5579)
+++ jpa/eclipselink.jpa.test/test.properties (working copy)
@@ -45,6 +45,9 @@
# Valid values of server.name are weblogic, websphere, jboss, oc4j, glassfish ...
server.name=weblogic
+# Set value to true if you want to validate container managed JPA using jndi lookup
+#ejb.lookup=true
+
# A property specifying if PromptTestRunner should save the test results to the database
should.save.results=false
Index: jpa/eclipselink.jpa.test/weblogic.xml
===================================================================
--- jpa/eclipselink.jpa.test/weblogic.xml (revision 5579)
+++ jpa/eclipselink.jpa.test/weblogic.xml (working copy)
@@ -106,6 +106,7 @@
+