mirror of https://github.com/apache/openjpa.git
make sure tests cleanup EMs and EMFs
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1006038 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a0fad7795b
commit
044164b4ad
|
@ -81,7 +81,7 @@ public class TestContainerSpecCompatibilityOptions
|
||||||
assertEquals("JPA", spec.getName().toUpperCase());
|
assertEquals("JPA", spec.getName().toUpperCase());
|
||||||
assertEquals(spec.getVersion(), 1);
|
assertEquals(spec.getVersion(), 1);
|
||||||
|
|
||||||
emf1.close();
|
closeEMF(emf1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ public class TestContainerSpecCompatibilityOptions
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
oemf.close();
|
closeEMF(oemf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ public class TestContainerSpecCompatibilityOptions
|
||||||
fail("OneToMany mapping failed with exception message: " + e.getMessage());
|
fail("OneToMany mapping failed with exception message: " + e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
em.close();
|
em.close();
|
||||||
oemf.close();
|
closeEMF(oemf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,16 +60,19 @@ public class TestQuerySQLCache extends SingleEMFTestCase {
|
||||||
props.put("openjpa.jdbc.QuerySQLCache",
|
props.put("openjpa.jdbc.QuerySQLCache",
|
||||||
"org.apache.openjpa.persistence.compatible.TestQuerySQLCache.BadCacheMap");
|
"org.apache.openjpa.persistence.compatible.TestQuerySQLCache.BadCacheMap");
|
||||||
|
|
||||||
|
OpenJPAEntityManagerFactorySPI emf1 = null;
|
||||||
try {
|
try {
|
||||||
OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI)OpenJPAPersistence.
|
emf1 = (OpenJPAEntityManagerFactorySPI)OpenJPAPersistence.
|
||||||
cast(Persistence.createEntityManagerFactory("test", props));
|
cast(Persistence.createEntityManagerFactory("test", props));
|
||||||
//
|
//
|
||||||
// EMF creation must throw an exception because the cache implementation class will not be found
|
// EMF creation must throw an exception because the cache implementation class will not be found
|
||||||
//
|
//
|
||||||
assertFalse(false);
|
fail("EMF creation must throw an exception because the cache implementation class will not be found");
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
|
} finally {
|
||||||
|
closeEMF(emf1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,9 +111,10 @@ public class TestQuerySQLCache extends SingleEMFTestCase {
|
||||||
+ TblParent.class.getName() + ")");
|
+ TblParent.class.getName() + ")");
|
||||||
props.put("openjpa.jdbc.QuerySQLCache", "true");
|
props.put("openjpa.jdbc.QuerySQLCache", "true");
|
||||||
|
|
||||||
OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.
|
OpenJPAEntityManagerFactorySPI emf1 = (OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.
|
||||||
cast(Persistence.createEntityManagerFactory("test", props));
|
cast(Persistence.createEntityManagerFactory("test", props));
|
||||||
EntityManagerImpl em = (EntityManagerImpl)emf.createEntityManager();
|
try {
|
||||||
|
EntityManagerImpl em = (EntityManagerImpl)emf1.createEntityManager();
|
||||||
|
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
|
||||||
|
@ -157,14 +161,17 @@ public class TestQuerySQLCache extends SingleEMFTestCase {
|
||||||
assertTrue(hasGrandChild);
|
assertTrue(hasGrandChild);
|
||||||
}
|
}
|
||||||
assertTrue(hasChild);
|
assertTrue(hasChild);
|
||||||
}
|
|
||||||
em.close();
|
em.close();
|
||||||
emf.close();
|
}
|
||||||
|
} finally {
|
||||||
|
closeEMF(emf1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void runMultiEMCaching(Map props) {
|
private void runMultiEMCaching(Map props) {
|
||||||
EntityManagerFactory emfac = Persistence.createEntityManagerFactory("test", props);
|
EntityManagerFactory emfac = Persistence.createEntityManagerFactory("test", props);
|
||||||
|
try {
|
||||||
EntityManager em = emfac.createEntityManager();
|
EntityManager em = emfac.createEntityManager();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -219,6 +226,9 @@ public class TestQuerySQLCache extends SingleEMFTestCase {
|
||||||
em.flush();
|
em.flush();
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
em.close();
|
em.close();
|
||||||
|
} finally {
|
||||||
|
closeEMF(emfac);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ extends AbstractCachedEMFTestCase {
|
||||||
"org/apache/openjpa/persistence/compat/" +
|
"org/apache/openjpa/persistence/compat/" +
|
||||||
"persistence_1_0.xml");
|
"persistence_1_0.xml");
|
||||||
|
|
||||||
|
try {
|
||||||
Compatibility compat = emf.getConfiguration().getCompatibilityInstance();
|
Compatibility compat = emf.getConfiguration().getCompatibilityInstance();
|
||||||
assertTrue(compat.getFlushBeforeDetach());
|
assertTrue(compat.getFlushBeforeDetach());
|
||||||
assertTrue(compat.getCopyOnDetach());
|
assertTrue(compat.getCopyOnDetach());
|
||||||
|
@ -64,8 +65,9 @@ extends AbstractCachedEMFTestCase {
|
||||||
Specification spec = emf.getConfiguration().getSpecificationInstance();
|
Specification spec = emf.getConfiguration().getSpecificationInstance();
|
||||||
assertEquals("JPA", spec.getName().toUpperCase());
|
assertEquals("JPA", spec.getName().toUpperCase());
|
||||||
assertEquals(spec.getVersion(), 1);
|
assertEquals(spec.getVersion(), 1);
|
||||||
|
} finally {
|
||||||
emf.close();
|
closeEMF(emf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -79,6 +81,7 @@ extends AbstractCachedEMFTestCase {
|
||||||
"org/apache/openjpa/persistence/compat/" +
|
"org/apache/openjpa/persistence/compat/" +
|
||||||
"persistence_2_0.xml");
|
"persistence_2_0.xml");
|
||||||
|
|
||||||
|
try {
|
||||||
Compatibility compat = emf.getConfiguration().getCompatibilityInstance();
|
Compatibility compat = emf.getConfiguration().getCompatibilityInstance();
|
||||||
assertFalse(compat.getFlushBeforeDetach());
|
assertFalse(compat.getFlushBeforeDetach());
|
||||||
assertFalse(compat.getCopyOnDetach());
|
assertFalse(compat.getCopyOnDetach());
|
||||||
|
@ -89,8 +92,9 @@ extends AbstractCachedEMFTestCase {
|
||||||
Specification spec = emf.getConfiguration().getSpecificationInstance();
|
Specification spec = emf.getConfiguration().getSpecificationInstance();
|
||||||
assertEquals("JPA", spec.getName().toUpperCase());
|
assertEquals("JPA", spec.getName().toUpperCase());
|
||||||
assertEquals(spec.getVersion(), 2);
|
assertEquals(spec.getVersion(), 2);
|
||||||
|
} finally {
|
||||||
emf.close();
|
closeEMF(emf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -125,7 +129,7 @@ extends AbstractCachedEMFTestCase {
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
emf.close();
|
closeEMF(emf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +198,7 @@ extends AbstractCachedEMFTestCase {
|
||||||
fail("OneToMany mapping failed with exception message: " + e.getMessage());
|
fail("OneToMany mapping failed with exception message: " + e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
em.close();
|
em.close();
|
||||||
emf.close();
|
closeEMF(emf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue