diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java index cee1e65ed..66d5128d1 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/AbstractPersistenceTestCase.java @@ -234,7 +234,9 @@ public abstract class AbstractPersistenceTestCase extends TestCase { } finally { emf.close(); brc = !emf.isOpen(); - emf = null; + if (!brc) { + System.err.println("AbstractPersistenceTestCase().closeEMF() - EMF is still open."); + } } return brc; } @@ -253,7 +255,11 @@ public abstract class AbstractPersistenceTestCase extends TestCase { em.getTransaction().rollback(); } em.close(); - return true; + boolean brc = !em.isOpen(); + if (!brc) { + System.err.println("AbstractPersistenceTestCase().closeEM() - EM is still open."); + } + return brc; } /** diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java index a8a6e8ade..ea2cba314 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java @@ -31,7 +31,8 @@ import org.apache.openjpa.lib.jdbc.JDBCListener; /** * Base class for tests that need to check generated SQL. - * Extends SingleEMFTestCase, which will cleanup the EMF it provides. + * Extends SingleEMFTestCase, which will cleanup the EMF it provides, + * along with any EMs generated by that EMF. * * @author Patrick Linskey */ diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java index e4787d610..c0b6d7265 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMFTestCase.java @@ -38,8 +38,8 @@ import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI; * OpenJPA-extended SPI interface OpenJPAEntityManagerFactorySPI * so that derived classes can access internal mapping/metadata/configuration * and other structures. - * Extends AbstractCachedEMFTestCase, which extends AbstractPersistenceTestCase - * and cleans up the EMF it provides in tearDown(). + * Extends AbstractCachedEMFTestCase, which extends AbstractPersistenceTestCase. + * Cleans up the EMF it provides and any EMs created from it in tearDown(). * */ public abstract class SingleEMFTestCase diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMTestCase.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMTestCase.java index bd4a3544e..ca85afc25 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMTestCase.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMTestCase.java @@ -59,8 +59,8 @@ public abstract class SingleEMTestCase @Override public void tearDown() throws Exception { - rollback(); - close(); + closeEM(em); + em = null; super.tearDown(); }