openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dez...@apache.org
Subject svn commit: r617577 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestSerializedFactory.java
Date Fri, 01 Feb 2008 17:53:56 GMT
Author: dezzio
Date: Fri Feb  1 09:53:48 2008
New Revision: 617577

URL: http://svn.apache.org/viewvc?rev=617577&view=rev
Log:
Rolledback change to AbstractBrokerFactory pending resolution of issues arising from r616972.
 Modified TestSerializedFactory to expect failure: it expects created EntityManagerFactory
objects to be instances of Serialization, but to not be useful after serialization.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestSerializedFactory.java

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=617577&r1=617576&r2=617577&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 Feb  1 09:53:48 2008
@@ -147,7 +147,8 @@
      */
     protected AbstractBrokerFactory(OpenJPAConfiguration config) {
         _conf = config;
-        getPcClassLoaders();
+        _pcClassLoaders = new ConcurrentReferenceHashSet(
+            ConcurrentReferenceHashSet.WEAK);
     }
 
     /**
@@ -286,13 +287,13 @@
                     if (needsSub(cls))
                         toRedefine.add(cls);
                 }
-                getPcClassLoaders().add(loader);
+                _pcClassLoaders.add(loader);
                 _pcClassNames = c;
             }
             _persistentTypesLoaded = true;
         } else {
             // reload with this loader
-            if (getPcClassLoaders().add(loader)) {
+            if (_pcClassLoaders.add(loader)) {
                 for (Iterator itr = _pcClassNames.iterator(); itr.hasNext();) {
                     try {
                         Class cls =
@@ -817,15 +818,4 @@
             _transactional.remove (_trans);
 		}
 	}
-   
-   /**
-    * Method insures that deserialized EMF has this reference re-instantiated
-    */
-   private Collection getPcClassLoaders() {
-      if (_pcClassLoaders == null)
-        _pcClassLoaders = new ConcurrentReferenceHashSet(
-            ConcurrentReferenceHashSet.WEAK);
-         
-      return _pcClassLoaders;
-   }
 }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestSerializedFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestSerializedFactory.java?rev=617577&r1=617576&r2=617577&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestSerializedFactory.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestSerializedFactory.java
Fri Feb  1 09:53:48 2008
@@ -40,7 +40,22 @@
         setUp(AllFieldTypes.class);
     }
 
+    /**
+     * This test case assumes that OpenJPA creates EMF objects that are 
+     * instances of the Serializable interface.  If this changes, the test
+     * logic has to change.
+     * <p>
+     * Currently, although the EMF objects implement Serializable, they
+     * do not successfully pass through serialization.  Once they do 
+     * (assuming they should), the catch block in the test and the
+     * fail method invocation can be removed.
+     */
     public void testSerializedEntityManagerFactory() throws Exception {
+        // correct the logic if and when EMFs do not implement 
+        // the serializable interface
+        assertTrue("EntityManagerFactory object is not serializable", 
+                emf instanceof Serializable);
+
         // serialize and deserialize the entity manager factory
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos);
@@ -48,23 +63,31 @@
         EntityManagerFactory emf2 = 
             (EntityManagerFactory) new ObjectInputStream(
             new ByteArrayInputStream(baos.toByteArray())).readObject();
-            
-        // use the deserialized entity manager factory
-        assertTrue("The deserialized entity manager factory is not open",
-            emf2.isOpen());
-        EntityManager em = emf2.createEntityManager();
-        assertTrue("The newly created entity manager is not open", em.isOpen());
 
-        // exercise the entity manager produced from the deserialized EMF
-        em.getTransaction().begin();
-        em.persist(new AllFieldTypes());
-        em.getTransaction().commit();
-        
-        // close the extra resources
-        em.close();
-        assertFalse("The entity manager is not closed", em.isOpen());
-        emf2.close();
-        assertFalse("The entity manager factory is not closed", emf2.isOpen());
+        try {
+            // use the deserialized entity manager factory
+            assertTrue("The deserialized entity manager factory is not open",
+                emf2.isOpen());
+            EntityManager em = emf2.createEntityManager();
+            assertTrue("The newly created entity manager is not open", em.isOpen());
+    
+            // exercise the entity manager produced from the deserialized EMF
+            em.getTransaction().begin();
+            em.persist(new AllFieldTypes());
+            em.getTransaction().commit();
+            
+            // close the extra resources
+            em.close();
+            assertFalse("The entity manager is not closed", em.isOpen());
+            emf2.close();
+            assertFalse("The entity manager factory is not closed", emf2.isOpen());
+            
+            // Correct the logic when EMF's are supposed to serialize
+            fail("This test is expected to fail until the issue of serializing an EMF is
settled");
+         }
+         catch (Exception e) {
+            // failure is currently expected
+         }
     }
     
     public static void main(String[] args) {



Mime
View raw message