make sure tests cleanup EMs and EMFs

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1005903 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-10-08 17:05:57 +00:00
parent e0a173f17e
commit 996abba172
10 changed files with 42 additions and 14 deletions

View File

@ -27,8 +27,10 @@ import javax.persistence.*;
import
org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.*;
import org.apache.openjpa.persistence.common.utils.*;
import org.apache.openjpa.persistence.test.AllowFailure;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
@AllowFailure(message="excluded")
public class TestAdvAnnot extends AnnotationTestCase
{
public TestAdvAnnot(String name)
@ -36,8 +38,7 @@ public class TestAdvAnnot extends AnnotationTestCase
super(name, "annotationcactusapp");
}
public void setUp()
{
public void setUp() {
deleteAll(Schedule.class);
deleteAll(FlightSchedule.class);

View File

@ -46,6 +46,7 @@ public class TestAnnotationBasics extends AnnotationTestCase {
ClassMetaData.ID_APPLICATION == meta.getIdentityType());
assertTrue("Entity1 should use single-field identity",
meta.isOpenJPAIdentity());
endEm(em);
}
/*
public void testVersionField() {

View File

@ -24,9 +24,11 @@ import junit.framework.*;
import javax.persistence.*;
import org.apache.openjpa.persistence.common.utils.*;
import org.apache.openjpa.persistence.test.AllowFailure;
import org.apache.openjpa.persistence.annotations.common.apps.annotApp.ddtype.*;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
@AllowFailure(message="excluded")
public class TestDDCallbackMethods extends AnnotationTestCase
{

View File

@ -33,6 +33,7 @@ import org.apache.openjpa.persistence.OpenJPAEntityManager;
import
org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.*;
import org.apache.openjpa.persistence.common.utils.*;
import org.apache.openjpa.persistence.test.AllowFailure;
import junit.framework.*;
@ -41,6 +42,7 @@ import junit.framework.*;
*
* @author Steve Kim
*/
@AllowFailure(message="excluded")
public class TestEJBEmbedded extends AnnotationTestCase
{

View File

@ -24,11 +24,13 @@ import javax.persistence.*;
import junit.framework.*;
import org.apache.openjpa.persistence.common.utils.*;
import org.apache.openjpa.persistence.test.AllowFailure;
import
org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.*;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
@AllowFailure(message="excluded")
public class TestEntityListenerAnnot extends AnnotationTestCase
{

View File

@ -27,6 +27,7 @@ import org.apache.openjpa.persistence.OpenJPAEntityManager;
import
org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.*;
import org.apache.openjpa.persistence.common.utils.*;
import org.apache.openjpa.persistence.test.AllowFailure;
import junit.framework.*;
@ -35,6 +36,7 @@ import junit.framework.*;
*
* @author Abe White
*/
@AllowFailure(message="excluded")
public class TestEntityOrderBy extends AnnotationTestCase
{

View File

@ -41,9 +41,8 @@ public class TestPersistentCollection extends SingleEMFTestCase {
@SuppressWarnings("unchecked")
public void testPersistentCollectionOfEmbeddables() {
try {
EntityManager em = emf.createEntityManager();
try {
em.getTransaction().begin();
PColl_EntityC c = new PColl_EntityC();
@ -59,6 +58,7 @@ public class TestPersistentCollection extends SingleEMFTestCase {
em.persist(a);
em.getTransaction().commit();
em.close();
em = null;
em = emf.createEntityManager();
Query q = em.createQuery("SELECT o FROM PColl_EntityA o");
@ -73,16 +73,19 @@ public class TestPersistentCollection extends SingleEMFTestCase {
assertEquals(101, c1.getId());
assertEquals(1, d1.getId());
em.close();
em = null;
} catch (Throwable t) {
fail(t.getMessage());
} finally {
if (em != null)
em.close();
}
}
@SuppressWarnings("unchecked")
public void testPersistentCollectionOfEntities() {
try {
EntityManager em = emf.createEntityManager();
try {
em.getTransaction().begin();
PColl_EntityC c = new PColl_EntityC();
@ -98,6 +101,7 @@ public class TestPersistentCollection extends SingleEMFTestCase {
em.persist(a);
em.getTransaction().commit();
em.close();
em = null;
em = emf.createEntityManager();
Query q = em.createQuery("SELECT o FROM PColl_EntityA1 o");
@ -113,15 +117,18 @@ public class TestPersistentCollection extends SingleEMFTestCase {
assertEquals(101, c1.getId());
assertEquals(1, a1.getId());
em.close();
em = null;
} catch (Throwable t) {
fail(t.getMessage());
} finally {
if (em != null)
em.close();
}
}
public void testPersistentCollectionStringsLazy() {
try {
EntityManager em = emf.createEntityManager();
try {
em.getTransaction().begin();
PColl_EntityStringLazy a = new PColl_EntityStringLazy();
@ -130,6 +137,7 @@ public class TestPersistentCollection extends SingleEMFTestCase {
em.persist(a);
em.getTransaction().commit();
em.close();
em = null;
em = emf.createEntityManager();
Query q = em.createQuery("SELECT o FROM PColl_EntityStringLazy o");
@ -139,15 +147,18 @@ public class TestPersistentCollection extends SingleEMFTestCase {
assertEquals("one", a1.getCollectionOfStrings().toArray()[0]);
assertEquals(1, a1.getId());
em.close();
em = null;
} catch (Throwable t) {
fail(t.getMessage());
} finally {
if (em != null)
em.close();
}
}
public void testPersistentCollectionStringsEager() {
try {
EntityManager em = emf.createEntityManager();
try {
em.getTransaction().begin();
PColl_EntityStringEager a = new PColl_EntityStringEager();
@ -156,6 +167,7 @@ public class TestPersistentCollection extends SingleEMFTestCase {
em.persist(a);
em.getTransaction().commit();
em.close();
em = null;
em = emf.createEntityManager();
Query q = em.createQuery("SELECT o FROM PColl_EntityStringEager o");
@ -165,8 +177,12 @@ public class TestPersistentCollection extends SingleEMFTestCase {
assertEquals("one", a1.getCollectionOfStrings().toArray()[0]);
assertEquals(1, a1.getId());
em.close();
em = null;
} catch (Throwable t) {
fail(t.getMessage());
} finally {
if (em != null)
em.close();
}
}
}

View File

@ -28,9 +28,9 @@ import
import junit.framework.*;
import org.apache.openjpa.persistence.common.utils.*;
import org.apache.openjpa.persistence.test.AllowFailure;
@AllowFailure(message="excluded")
public class TestPropertyAccess extends AnnotationTestCase
{
public TestPropertyAccess(String name)

View File

@ -26,6 +26,7 @@ import org.apache.openjpa.jdbc.meta.strats.* ;
import
org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.*;
import org.apache.openjpa.persistence.test.AllowFailure;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
@ -36,6 +37,7 @@ import org.apache.openjpa.persistence.OpenJPAPersistence;
@author Steve Kim
*/
@AllowFailure(message="excluded")
public class TestVersion extends AnnotationTestCase
{
private Object oid;