[nobug] close EMs in tests
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/jpql/AdvancedQueryTestSuite.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/jpql/AdvancedQueryTestSuite.java
index ff0a91f..a275504 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/jpql/AdvancedQueryTestSuite.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/jpql/AdvancedQueryTestSuite.java
@@ -166,6 +166,7 @@
suite.addTest(new AdvancedQueryTestSuite("testVersionChangeWithWriteLock"));
suite.addTest(new AdvancedQueryTestSuite("testNamedQueryAnnotationOverwritePersistenceXML"));
}
+ suite.addTest(new AdvancedQueryTestSuite("testTearDown"));
return suite;
}
@@ -199,6 +200,10 @@
inheritancePopulator.persistExample(session);
}
+ public void testTearDown() {
+ JUnitTestCase.closeEntityManagerFactory(getPersistenceUnitName());
+ }
+
/**
* Test that a cache hit will occur on a primary key query.
*/
@@ -983,7 +988,7 @@
rollbackTransaction(em2);
throw ex;
} finally {
- closeEntityManager(em2);
+ closeEntityManagerAndTransaction(em2);
}
try {
@@ -1045,6 +1050,8 @@
rollbackTransaction(em2);
closeEntityManager(em2);
throw ex;
+ } finally {
+ closeEntityManagerAndTransaction(em2);
}
commitTransaction(em);
@@ -1060,6 +1067,8 @@
closeEntityManager(em);
throw ex;
+ } finally {
+ closeEntityManagerAndTransaction(em);
}
assertFalse("Proper exception not thrown when Query with LockModeType.WRITE is used.", optimisticLockException == null);
@@ -1097,7 +1106,7 @@
rollbackTransaction(em2);
throw ex;
} finally {
- closeEntityManager(em2);
+ closeEntityManagerAndTransaction(em2);
}
try {
@@ -1155,8 +1164,9 @@
commitTransaction(em2);
} catch (RuntimeException ex) {
rollbackTransaction(em2);
- closeEntityManager(em2);
throw ex;
+ } finally {
+ closeEntityManagerAndTransaction(em2);
}
commitTransaction(em);
@@ -1172,6 +1182,8 @@
closeEntityManager(em);
throw ex;
+ } finally {
+ closeEntityManagerAndTransaction(em);
}
assertFalse("Proper exception not thrown when Query with LockModeType.WRITE is used.", optimisticLockException == null);