View | Details | Raw Unified | Return to bug 292951 | Differences between
and this patch

Collapse All | Expand All

(-)jpa/eclipselink.jpa.test/resource/server/ejb-jar.xml (-2 / +2 lines)
Lines 8-18 Link Here
8
        <session>
8
        <session>
9
            <ejb-name>TestRunner</ejb-name>
9
            <ejb-name>TestRunner</ejb-name>
10
            <persistence-context-ref>
10
            <persistence-context-ref>
11
                <persistence-context-ref-name>persistence/entity-manager</persistence-context-ref-name>
11
                <persistence-context-ref-name>persistence/default/entity-manager</persistence-context-ref-name>
12
                <persistence-unit-name>%%default%%</persistence-unit-name>
12
                <persistence-unit-name>%%default%%</persistence-unit-name>
13
            </persistence-context-ref>
13
            </persistence-context-ref>
14
            <persistence-unit-ref>
14
            <persistence-unit-ref>
15
                <persistence-unit-ref-name>persistence/factory</persistence-unit-ref-name>
15
                <persistence-unit-ref-name>persistence/default/factory</persistence-unit-ref-name>
16
                <persistence-unit-name>%%default%%</persistence-unit-name>
16
                <persistence-unit-name>%%default%%</persistence-unit-name>
17
            </persistence-unit-ref>
17
            </persistence-unit-ref>
18
        </session>
18
        </session>
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/framework/server/JEEPlatform.java (-14 / +21 lines)
Lines 33-38 Link Here
33
    /** The entity manager factory for the test is injected and passed to the test server platform. */
33
    /** The entity manager factory for the test is injected and passed to the test server platform. */
34
    public static EntityManagerFactory entityManagerFactory;
34
    public static EntityManagerFactory entityManagerFactory;
35
35
36
    /** The variable for getting entity manager by jndi lookup, set it to true in test.properties if you want jndi lookup */
37
    public static final String EJB_LOOKUP = "ejb.lookup";
38
36
    /**
39
    /**
37
     * Nothing required in JEE.
40
     * Nothing required in JEE.
38
     */
41
     */
Lines 152-181 Link Here
152
     * Return the managed EntityManager for the persistence unit.
155
     * Return the managed EntityManager for the persistence unit.
153
     */
156
     */
154
    public EntityManager getEntityManager(String persistenceUnit) {
157
    public EntityManager getEntityManager(String persistenceUnit) {
155
        if (entityManager != null) {
158
        String property = System.getProperty(EJB_LOOKUP);
159
        if (property == null || !property.toUpperCase().equals("TRUE")){
156
            return entityManager;
160
            return entityManager;
161
        } else {
162
            String contextName = "java:comp/env/persistence/" + persistenceUnit + "/entity-manager";
163
            try {
164
                return (EntityManager)new InitialContext().lookup(contextName);
165
            } catch (NamingException exception) {
166
                throw new RuntimeException(exception);
167
            }
157
        }
168
        }
158
        String contextName = "java:comp/env/persistence/" + persistenceUnit + "/entity-manager";
159
        try {
160
            return (EntityManager)new InitialContext().lookup(contextName);
161
        } catch (NamingException exception) {
162
            throw new RuntimeException(exception);
163
        }
164
    }
169
    }
165
    
170
    
166
    /**
171
    /**
167
     * Return the managed EntityManagerFactory for the persistence unit.
172
     * Return the managed EntityManagerFactory for the persistence unit.
168
     */
173
     */
169
    public EntityManagerFactory getEntityManagerFactory(String persistenceUnit) {
174
    public EntityManagerFactory getEntityManagerFactory(String persistenceUnit) {
170
        if (entityManagerFactory != null) {
175
        String property = System.getProperty(EJB_LOOKUP);
176
        if (property == null || !property.toUpperCase().equals("TRUE")){
171
            return entityManagerFactory;
177
            return entityManagerFactory;
178
        } else{
179
            String contextName = "java:comp/env/persistence/" + persistenceUnit + "/factory";
180
            try {
181
                return (EntityManagerFactory)new InitialContext().lookup(contextName);
182
            } catch (NamingException exception) {
183
                throw new RuntimeException(exception);
184
            }
172
        }
185
        }
173
        String contextName = "java:comp/env/persistence/" + persistenceUnit + "/factory";
174
        try {
175
            return (EntityManagerFactory)new InitialContext().lookup(contextName);
176
        } catch (NamingException exception) {
177
            throw new RuntimeException(exception);
178
        }
179
    }
186
    }
180
    
187
    
181
}
188
}
(-)jpa/eclipselink.jpa.test/test.properties (+3 lines)
Lines 45-50 Link Here
45
# Valid values of server.name are weblogic, websphere, jboss, oc4j, glassfish ...
45
# Valid values of server.name are weblogic, websphere, jboss, oc4j, glassfish ...
46
server.name=weblogic
46
server.name=weblogic
47
47
48
# Set value to true if you want to validate container managed JPA using jndi lookup
49
#ejb.lookup=true
50
48
# A property specifying if PromptTestRunner should save the test results to the database
51
# A property specifying if PromptTestRunner should save the test results to the database
49
should.save.results=false
52
should.save.results=false
50
53
(-)jpa/eclipselink.jpa.test/weblogic.xml (+1 lines)
Lines 106-111 Link Here
106
            <!--sysproperty key="http.proxyHost" value="www-proxy.us.oracle.com"/-->
106
            <!--sysproperty key="http.proxyHost" value="www-proxy.us.oracle.com"/-->
107
            <!--sysproperty key="http.proxyPort" value="80"/-->
107
            <!--sysproperty key="http.proxyPort" value="80"/-->
108
            <sysproperty key="eclipselink.logging.level" value="${logging.level}"/>
108
            <sysproperty key="eclipselink.logging.level" value="${logging.level}"/>
109
            <sysproperty key="ejb.lookup" value="${ejb.lookup}"/>
109
        </wlserver>
110
        </wlserver>
110
    </target>
111
    </target>
111
112

Return to bug 292951