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;
|
private static OpenJPAEntityManagerFactorySPI emf = null;
|
||||||
|
|
||||||
public void setUp() {
|
@Override
|
||||||
|
public void setUp() throws Exception {
|
||||||
if (emf == null) {
|
if (emf == null) {
|
||||||
emf = createEMF(AnEntity.class);
|
emf = createEMF(AnEntity.class);
|
||||||
}
|
}
|
||||||
|
@ -62,6 +63,12 @@ public class TestBeforeCommit extends AbstractPersistenceTestCase implements Tra
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tearDown() {
|
||||||
|
closeEMF(emf);
|
||||||
|
emf = null;
|
||||||
|
}
|
||||||
|
|
||||||
public void testQuery() {
|
public void testQuery() {
|
||||||
OpenJPAEntityManagerSPI em = (OpenJPAEntityManagerSPI) emf.createEntityManager();
|
OpenJPAEntityManagerSPI em = (OpenJPAEntityManagerSPI) emf.createEntityManager();
|
||||||
em.addTransactionListener(this);
|
em.addTransactionListener(this);
|
||||||
|
@ -131,6 +138,7 @@ public class TestBeforeCommit extends AbstractPersistenceTestCase implements Tra
|
||||||
assertEquals("", ae.getName());
|
assertEquals("", ae.getName());
|
||||||
}
|
}
|
||||||
assertEquals(1, ae.getVersion());
|
assertEquals(1, ae.getVersion());
|
||||||
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beforeCommit(TransactionEvent event) {
|
public void beforeCommit(TransactionEvent event) {
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class TestPostRemove extends ContainerTest {
|
||||||
commit();
|
commit();
|
||||||
assertTrue("PostRemove not called after commit", isPostRemovedInvoked(pc)
|
assertTrue("PostRemove not called after commit", isPostRemovedInvoked(pc)
|
||||||
&& pc.getPostRemoveTime() <= System.nanoTime());
|
&& pc.getPostRemoveTime() <= System.nanoTime());
|
||||||
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPostRemoveInvokedAfterDatabaseDeleteWithoutFlush() {
|
public void testPostRemoveInvokedAfterDatabaseDeleteWithoutFlush() {
|
||||||
|
@ -73,6 +74,7 @@ public class TestPostRemove extends ContainerTest {
|
||||||
assertFalse("PostRemove called before commit", isPostRemovedInvoked(pc));
|
assertFalse("PostRemove called before commit", isPostRemovedInvoked(pc));
|
||||||
commit();
|
commit();
|
||||||
assertTrue("PostRemove not called after commit", pc.getPostRemoveTime() <= System.nanoTime());
|
assertTrue("PostRemove not called after commit", pc.getPostRemoveTime() <= System.nanoTime());
|
||||||
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPostRemoveNotInvokedAfterRollback() {
|
public void testPostRemoveNotInvokedAfterRollback() {
|
||||||
|
@ -84,6 +86,7 @@ public class TestPostRemove extends ContainerTest {
|
||||||
assertFalse("PostRemove called before rollback", isPostRemovedInvoked(pc));
|
assertFalse("PostRemove called before rollback", isPostRemovedInvoked(pc));
|
||||||
rollback();
|
rollback();
|
||||||
assertTrue("PostRemove called after rollback", pc.getPostRemoveTime() <= System.nanoTime());
|
assertTrue("PostRemove called after rollback", pc.getPostRemoveTime() <= System.nanoTime());
|
||||||
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPostRemoveNotInvokedAfterRollbackWithIntermediateFlush() {
|
public void testPostRemoveNotInvokedAfterRollbackWithIntermediateFlush() {
|
||||||
|
@ -97,6 +100,7 @@ public class TestPostRemove extends ContainerTest {
|
||||||
assertFalse("PostRemove called before rollback", isPostRemovedInvoked(pc));
|
assertFalse("PostRemove called before rollback", isPostRemovedInvoked(pc));
|
||||||
rollback();
|
rollback();
|
||||||
assertTrue("PostRemove called after rollback", pc.getPostRemoveTime() <= System.nanoTime());
|
assertTrue("PostRemove called after rollback", pc.getPostRemoveTime() <= System.nanoTime());
|
||||||
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPostRemoveInvokedOnFlushThatIssuesDatabaseDelete() {
|
public void testPostRemoveInvokedOnFlushThatIssuesDatabaseDelete() {
|
||||||
|
@ -117,6 +121,7 @@ public class TestPostRemove extends ContainerTest {
|
||||||
assertTrue("PostRemove not called after delete flush", isPostRemovedInvoked(pc));
|
assertTrue("PostRemove not called after delete flush", isPostRemovedInvoked(pc));
|
||||||
commit();
|
commit();
|
||||||
assertTrue("PostRemove not called after commit", pc.getPostRemoveTime() <= System.nanoTime());
|
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));
|
assertFalse("PostRemove called before commit", isPostRemovedInvoked(pc));
|
||||||
commit();
|
commit();
|
||||||
assertFalse("PostRemove called after commit", isPostRemovedInvoked(pc));
|
assertFalse("PostRemove called after commit", isPostRemovedInvoked(pc));
|
||||||
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isPostRemovedInvoked(PostRemoveCallbackEntity pc) {
|
boolean isPostRemovedInvoked(PostRemoveCallbackEntity pc) {
|
||||||
|
|
|
@ -122,6 +122,7 @@ public class TestException extends SingleEMFTestCase {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
assertException(t, EntityExistsException.class);
|
assertException(t, EntityExistsException.class);
|
||||||
}
|
}
|
||||||
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testThrowsEntityNotFoundException() {
|
public void testThrowsEntityNotFoundException() {
|
||||||
|
@ -147,6 +148,7 @@ public class TestException extends SingleEMFTestCase {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
assertException(t, EntityNotFoundException.class);
|
assertException(t, EntityNotFoundException.class);
|
||||||
}
|
}
|
||||||
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testErrorCodeConfigurationHasAllKnownDictionaries() {
|
public void testErrorCodeConfigurationHasAllKnownDictionaries() {
|
||||||
|
@ -179,6 +181,7 @@ public class TestException extends SingleEMFTestCase {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
assertException(t, IllegalArgumentException.class);
|
assertException(t, IllegalArgumentException.class);
|
||||||
}
|
}
|
||||||
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,6 +195,7 @@ public class TestException extends SingleEMFTestCase {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
assertException(t, IllegalArgumentException.class);
|
assertException(t, IllegalArgumentException.class);
|
||||||
}
|
}
|
||||||
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue