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@1022699 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
db1ce09390
commit
8cafaf9f19
|
@ -78,6 +78,7 @@ public class TestAutoIncrement extends SingleEMFTestCase {
|
|||
em.getTransaction().commit();
|
||||
|
||||
assertEquals(1, Math.abs(pc1.getId() - pc2.getId()));
|
||||
em.close();
|
||||
}
|
||||
|
||||
public void testAutoIncrementIdentityWithNativeSequence() {
|
||||
|
@ -90,6 +91,7 @@ public class TestAutoIncrement extends SingleEMFTestCase {
|
|||
em.getTransaction().commit();
|
||||
|
||||
assertEquals(1, Math.abs(pc1.getId() - pc2.getId()));
|
||||
em.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,6 +110,7 @@ public class TestAutoIncrement extends SingleEMFTestCase {
|
|||
// Sequence probably exists.
|
||||
em.getTransaction().rollback();
|
||||
}
|
||||
closeEM(em);
|
||||
closeEMF(factorySPI);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,16 +129,23 @@ public class TestFlushBeforeDetach extends SQLListenerTestCase {
|
|||
*/
|
||||
private Object serializeObject(Object orig) throws Exception {
|
||||
Object deserialized = null;
|
||||
ObjectOutputStream oos = null;
|
||||
ObjectInputStream ois = null;
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(orig);
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(orig);
|
||||
|
||||
ByteArrayInputStream bais =
|
||||
new ByteArrayInputStream(baos.toByteArray());
|
||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
ByteArrayInputStream bais =
|
||||
new ByteArrayInputStream(baos.toByteArray());
|
||||
ois = new ObjectInputStream(bais);
|
||||
|
||||
deserialized = ois.readObject();
|
||||
return deserialized;
|
||||
deserialized = ois.readObject();
|
||||
return deserialized;
|
||||
} finally {
|
||||
oos.close();
|
||||
ois.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ public class TestMissingMetaData extends TestCase {
|
|||
|
||||
public void tearDown() {
|
||||
emf.close();
|
||||
emf = null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.apache.openjpa.persistence.AutoClearType;
|
|||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||
import org.apache.openjpa.persistence.test.AbstractPersistenceTestCase;
|
||||
|
||||
/**
|
||||
* This test case tests the getProperties() and getSupportedProperties() methods
|
||||
|
@ -43,16 +44,16 @@ import org.apache.openjpa.persistence.OpenJPAPersistence;
|
|||
* @author Pinaki Poddar
|
||||
*
|
||||
*/
|
||||
public class TestPropertiesMethods extends TestCase {
|
||||
public class TestPropertiesMethods extends AbstractPersistenceTestCase {
|
||||
private static final String UNIT_NAME = "test";
|
||||
private static OpenJPAEntityManagerFactory emf;
|
||||
private OpenJPAEntityManagerFactory emf;
|
||||
private OpenJPAEntityManager em;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setUp() throws Exception {
|
||||
if (emf == null) {
|
||||
Map config = new HashMap();
|
||||
config.putAll(System.getProperties());
|
||||
super.setUp();
|
||||
Map config = new HashMap();
|
||||
config.putAll(System.getProperties());
|
||||
|
||||
/* numeric */ config.put("openjpa.DataCacheTimeout", 300);
|
||||
/* num enum */ config.put("openjpa.AutoClear", 0);
|
||||
|
@ -64,12 +65,19 @@ public class TestPropertiesMethods extends TestCase {
|
|||
/* equiv key */ //config.put("javax.persistence.jdbc.url", "jdbc:derby:target/database/test;create=true");
|
||||
/* prime use */ //config.put("openjpa.ConnectionUserName", "root");
|
||||
|
||||
emf = OpenJPAPersistence.cast(Persistence.createEntityManagerFactory(UNIT_NAME, config));
|
||||
assertNotNull(emf);
|
||||
}
|
||||
emf = OpenJPAPersistence.cast(Persistence.createEntityManagerFactory(UNIT_NAME, config));
|
||||
assertNotNull(emf);
|
||||
em = OpenJPAPersistence.cast(emf.createEntityManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() {
|
||||
closeEM(em);
|
||||
em = null;
|
||||
closeEMF(emf);
|
||||
emf = null;
|
||||
}
|
||||
|
||||
// public void testProperties() {
|
||||
// print("EMF Properties", emf.getProperties());
|
||||
// print("EMF Supported Properties", emf.getSupportedProperties());
|
||||
|
|
|
@ -82,6 +82,8 @@ public class TestSerializedFactory extends SingleEMFTestCase {
|
|||
emf2.close();
|
||||
assertFalse("The entity manager factory is not closed",
|
||||
emf2.isOpen());
|
||||
emf2 = null;
|
||||
oos.close();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -62,6 +62,7 @@ public class TestValidationFactory extends SingleEMFTestCase {
|
|||
assertEquals("Default ValidationFactory",
|
||||
null,
|
||||
conf.getValidationFactoryInstance());
|
||||
closeEMF(emf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,6 +92,7 @@ public class TestValidationFactory extends SingleEMFTestCase {
|
|||
assertEquals("ValidationFactory",
|
||||
this.getClass(),
|
||||
conf.getValidationFactoryInstance());
|
||||
closeEMF(emf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,6 +122,7 @@ public class TestValidationFactory extends SingleEMFTestCase {
|
|||
assertEquals("ValidationFactory",
|
||||
this.getClass(),
|
||||
conf.getValidationFactoryInstance());
|
||||
closeEMF(emf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,6 +162,7 @@ public class TestValidationFactory extends SingleEMFTestCase {
|
|||
getLog().trace("testValidationFactory4() - caught expected " +
|
||||
"PersistenceException", e);
|
||||
}
|
||||
closeEMF(emf);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue