openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r1022206 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence: event/TestBeforeCommit.java event/TestPostRemove.java exception/TestException.java
Date Wed, 13 Oct 2010 17:32:51 GMT
Author: dwoods
Date: Wed Oct 13 17:32:48 2010
New Revision: 1022206

URL: http://svn.apache.org/viewvc?rev=1022206&view=rev
Log:
make sure tests close EMs

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestBeforeCommit.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestPostRemove.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/exception/TestException.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestBeforeCommit.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestBeforeCommit.java?rev=1022206&r1=1022205&r2=1022206&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestBeforeCommit.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestBeforeCommit.java
Wed Oct 13 17:32:48 2010
@@ -41,7 +41,8 @@ public class TestBeforeCommit extends Ab
 
     private static OpenJPAEntityManagerFactorySPI emf = null;
 
-    public void setUp() {
+    @Override
+    public void setUp() throws Exception {
         if (emf == null) {
             emf = createEMF(AnEntity.class);
         }
@@ -62,6 +63,12 @@ public class TestBeforeCommit extends Ab
         em.close();
     }
 
+    @Override
+    public void tearDown() {
+        closeEMF(emf);
+        emf = null;
+    }
+    
     public void testQuery() {
         OpenJPAEntityManagerSPI em = (OpenJPAEntityManagerSPI) emf.createEntityManager();
         em.addTransactionListener(this);
@@ -131,6 +138,7 @@ public class TestBeforeCommit extends Ab
             assertEquals("", ae.getName());
         }
         assertEquals(1, ae.getVersion());
+        em.close();
     }
 
     public void beforeCommit(TransactionEvent event) {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestPostRemove.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestPostRemove.java?rev=1022206&r1=1022205&r2=1022206&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestPostRemove.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/event/TestPostRemove.java
Wed Oct 13 17:32:48 2010
@@ -62,6 +62,7 @@ public class TestPostRemove extends Cont
         commit();
         assertTrue("PostRemove not called after commit", isPostRemovedInvoked(pc) 
                 && pc.getPostRemoveTime() <= System.nanoTime());
+        em.close();
     }
     
     public void testPostRemoveInvokedAfterDatabaseDeleteWithoutFlush() {
@@ -73,6 +74,7 @@ public class TestPostRemove extends Cont
         assertFalse("PostRemove called before commit", isPostRemovedInvoked(pc));
         commit();
         assertTrue("PostRemove not called after commit", pc.getPostRemoveTime() <= System.nanoTime());
+        em.close();
     }
     
     public void testPostRemoveNotInvokedAfterRollback() {
@@ -84,6 +86,7 @@ public class TestPostRemove extends Cont
         assertFalse("PostRemove called before rollback", isPostRemovedInvoked(pc));
         rollback();
         assertTrue("PostRemove called after rollback", pc.getPostRemoveTime() <= System.nanoTime());
+        em.close();
     }
     
     public void testPostRemoveNotInvokedAfterRollbackWithIntermediateFlush() {
@@ -97,6 +100,7 @@ public class TestPostRemove extends Cont
         assertFalse("PostRemove called before rollback", isPostRemovedInvoked(pc));
         rollback();
         assertTrue("PostRemove called after rollback", pc.getPostRemoveTime() <= System.nanoTime());
+        em.close();
     }
     
     public void testPostRemoveInvokedOnFlushThatIssuesDatabaseDelete() {
@@ -117,6 +121,7 @@ public class TestPostRemove extends Cont
         assertTrue("PostRemove not called after delete flush", isPostRemovedInvoked(pc));
         commit();
         assertTrue("PostRemove not called after commit", pc.getPostRemoveTime() <= System.nanoTime());
+        em.close();
     }
 
 
@@ -128,6 +133,7 @@ public class TestPostRemove extends Cont
         assertFalse("PostRemove called before commit", isPostRemovedInvoked(pc));
         commit();
         assertFalse("PostRemove called after commit", isPostRemovedInvoked(pc));
+        em.close();
     }
     
     boolean isPostRemovedInvoked(PostRemoveCallbackEntity pc) {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/exception/TestException.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/exception/TestException.java?rev=1022206&r1=1022205&r2=1022206&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/exception/TestException.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/exception/TestException.java
Wed Oct 13 17:32:48 2010
@@ -122,6 +122,7 @@ public class TestException extends Singl
 		} catch (Throwable t) {
 			assertException(t, EntityExistsException.class);
 		}
+		em.close();
 	}
 	
 	public void testThrowsEntityNotFoundException() {
@@ -147,6 +148,7 @@ public class TestException extends Singl
 		} catch (Throwable t) {
 			assertException(t, EntityNotFoundException.class);
 		}
+		em.close();
 	}
 	
 	public void testErrorCodeConfigurationHasAllKnownDictionaries() {
@@ -179,6 +181,7 @@ public class TestException extends Singl
 	    } catch (Throwable t) {
 		   assertException(t, IllegalArgumentException.class);
 	    }
+	    em.close();
 	}
 	
 	/**
@@ -192,6 +195,7 @@ public class TestException extends Singl
          } catch (Throwable t) {
              assertException(t, IllegalArgumentException.class);
          }
+         em.close();
       }
 	
 	/**



Mime
View raw message