openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r578260 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/conf/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/ openjpa-persistence-jdb...
Date Fri, 21 Sep 2007 20:38:32 GMT
Author: mikedd
Date: Fri Sep 21 13:38:31 2007
New Revision: 578260

URL: http://svn.apache.org/viewvc?rev=578260&view=rev
Log:
OPENJPA-380

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestEntityManagerFactory.java
  (with props)
Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java?rev=578260&r1=578259&r2=578260&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java
Fri Sep 21 13:38:31 2007
@@ -611,6 +611,14 @@
      * @since 0.3.0
      */
     public MetaDataRepository getMetaDataRepositoryInstance();
+    
+    /**
+     * Returns true if a metaDataRepository has been created for this 
+     * configuration.
+     * 
+     * @since 1.1.0 1.0.1
+     */
+    public boolean metaDataRepositoryAvailable();
 
     /**
      * Create a new empty metadata repository of the configured type.

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java?rev=578260&r1=578259&r2=578260&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
Fri Sep 21 13:38:31 2007
@@ -834,6 +834,10 @@
             metaRepository = newMetaDataRepositoryInstance();
         return metaRepository;
     }
+    
+    public boolean metaDataRepositoryAvailable(){ 
+        return metaRepository != null; 
+    }
 
     public MetaDataRepository newMetaDataRepositoryInstance() {
         return (MetaDataRepository) metaRepositoryPlugin.instantiate(

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java?rev=578260&r1=578259&r2=578260&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
Fri Sep 21 13:38:31 2007
@@ -389,9 +389,11 @@
                     broker.close();
             }
 
-            // remove metadata repository from listener list
-            PCRegistry.removeRegisterClassListener
-                (_conf.getMetaDataRepositoryInstance());
+            if(_conf.metaDataRepositoryAvailable()) {
+                // remove metadata repository from listener list
+                PCRegistry.removeRegisterClassListener
+                    (_conf.getMetaDataRepositoryInstance());
+            }
 
             _conf.close();
             _closed = true;

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestEntityManagerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestEntityManagerFactory.java?rev=578260&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestEntityManagerFactory.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestEntityManagerFactory.java
Fri Sep 21 13:38:31 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.simple;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import junit.framework.TestCase;
+
+public class TestEntityManagerFactory extends TestCase {
+
+    /*
+     * This test uses a mis-configured persistence unit to verify that we will
+     * not connect to the database when an unused emf is closed.  
+     */
+    public void testCloseUnusedEMF() {
+        EntityManagerFactory emf =
+                Persistence.createEntityManagerFactory("invalid");
+        emf.close();
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestEntityManagerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml?rev=578260&r1=578259&r2=578260&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml Fri
Sep 21 13:38:31 2007
@@ -54,4 +54,13 @@
                 value="buildSchema(ForeignKeys=true)"/>
         </properties>
     </persistence-unit>
+    
+    <persistence-unit name="invalid">
+        <properties>
+            <property name="openjpa.ConnectionDriverName"
+                value="org.apache.commons.dbcp.BasicDataSource" />
+            <property name="openjpa.ConnectionProperties"
+                value="DriverClassName=not.a.real.Driver,Url=jdbc:notreal://"/>
+        </properties>
+    </persistence-unit>
 </persistence>



Mime
View raw message