mirror of https://github.com/apache/openjpa.git
make sure tests close EMs
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1022206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ebdc670298
commit
172ec292a7
|
@ -41,7 +41,8 @@ public class TestBeforeCommit extends AbstractPersistenceTestCase implements Tra
|
|||
|
||||
private static OpenJPAEntityManagerFactorySPI emf = null;
|
||||
|
||||
public void setUp() {
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
if (emf == null) {
|
||||
emf = createEMF(AnEntity.class);
|
||||
}
|
||||
|
@ -62,6 +63,12 @@ public class TestBeforeCommit extends AbstractPersistenceTestCase implements Tra
|
|||
em.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() {
|
||||
closeEMF(emf);
|
||||
emf = null;
|
||||
}
|
||||
|
||||
public void testQuery() {
|
||||
OpenJPAEntityManagerSPI em = (OpenJPAEntityManagerSPI) emf.createEntityManager();
|
||||
em.addTransactionListener(this);
|
||||
|
@ -131,6 +138,7 @@ public class TestBeforeCommit extends AbstractPersistenceTestCase implements Tra
|
|||
assertEquals("", ae.getName());
|
||||
}
|
||||
assertEquals(1, ae.getVersion());
|
||||
em.close();
|
||||
}
|
||||
|
||||
public void beforeCommit(TransactionEvent event) {
|
||||
|
|
|
@ -62,6 +62,7 @@ public class TestPostRemove extends ContainerTest {
|
|||
commit();
|
||||
assertTrue("PostRemove not called after commit", isPostRemovedInvoked(pc)
|
||||
&& pc.getPostRemoveTime() <= System.nanoTime());
|
||||
em.close();
|
||||
}
|
||||
|
||||
public void testPostRemoveInvokedAfterDatabaseDeleteWithoutFlush() {
|
||||
|
@ -73,6 +74,7 @@ public class TestPostRemove extends ContainerTest {
|
|||
assertFalse("PostRemove called before commit", isPostRemovedInvoked(pc));
|
||||
commit();
|
||||
assertTrue("PostRemove not called after commit", pc.getPostRemoveTime() <= System.nanoTime());
|
||||
em.close();
|
||||
}
|
||||
|
||||
public void testPostRemoveNotInvokedAfterRollback() {
|
||||
|
@ -84,6 +86,7 @@ public class TestPostRemove extends ContainerTest {
|
|||
assertFalse("PostRemove called before rollback", isPostRemovedInvoked(pc));
|
||||
rollback();
|
||||
assertTrue("PostRemove called after rollback", pc.getPostRemoveTime() <= System.nanoTime());
|
||||
em.close();
|
||||
}
|
||||
|
||||
public void testPostRemoveNotInvokedAfterRollbackWithIntermediateFlush() {
|
||||
|
@ -97,6 +100,7 @@ public class TestPostRemove extends ContainerTest {
|
|||
assertFalse("PostRemove called before rollback", isPostRemovedInvoked(pc));
|
||||
rollback();
|
||||
assertTrue("PostRemove called after rollback", pc.getPostRemoveTime() <= System.nanoTime());
|
||||
em.close();
|
||||
}
|
||||
|
||||
public void testPostRemoveInvokedOnFlushThatIssuesDatabaseDelete() {
|
||||
|
@ -117,6 +121,7 @@ public class TestPostRemove extends ContainerTest {
|
|||
assertTrue("PostRemove not called after delete flush", isPostRemovedInvoked(pc));
|
||||
commit();
|
||||
assertTrue("PostRemove not called after commit", pc.getPostRemoveTime() <= System.nanoTime());
|
||||
em.close();
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,6 +133,7 @@ public class TestPostRemove extends ContainerTest {
|
|||
assertFalse("PostRemove called before commit", isPostRemovedInvoked(pc));
|
||||
commit();
|
||||
assertFalse("PostRemove called after commit", isPostRemovedInvoked(pc));
|
||||
em.close();
|
||||
}
|
||||
|
||||
boolean isPostRemovedInvoked(PostRemoveCallbackEntity pc) {
|
||||
|
|
|
@ -122,6 +122,7 @@ public class TestException extends SingleEMFTestCase {
|
|||
} catch (Throwable t) {
|
||||
assertException(t, EntityExistsException.class);
|
||||
}
|
||||
em.close();
|
||||
}
|
||||
|
||||
public void testThrowsEntityNotFoundException() {
|
||||
|
@ -147,6 +148,7 @@ public class TestException extends SingleEMFTestCase {
|
|||
} catch (Throwable t) {
|
||||
assertException(t, EntityNotFoundException.class);
|
||||
}
|
||||
em.close();
|
||||
}
|
||||
|
||||
public void testErrorCodeConfigurationHasAllKnownDictionaries() {
|
||||
|
@ -179,6 +181,7 @@ public class TestException extends SingleEMFTestCase {
|
|||
} catch (Throwable t) {
|
||||
assertException(t, IllegalArgumentException.class);
|
||||
}
|
||||
em.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -192,6 +195,7 @@ public class TestException extends SingleEMFTestCase {
|
|||
} catch (Throwable t) {
|
||||
assertException(t, IllegalArgumentException.class);
|
||||
}
|
||||
em.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue