From 468743d2a7e0e38c46b9c132899d6c17c6d8d054 Mon Sep 17 00:00:00 2001 From: Juraci Krohling Date: Wed, 10 Dec 2008 12:01:47 +0000 Subject: [PATCH] EJB-407 - Fixing the test cases, to close the EM and/or finish the active transaction git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15676 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../java/org/hibernate/ejb/test/callbacks/CallbacksTest.java | 1 + .../src/test/java/org/hibernate/ejb/test/emops/FlushTest.java | 3 +++ .../java/org/hibernate/ejb/test/exception/ExceptionTest.java | 1 + .../src/test/java/org/hibernate/ejb/test/lock/LockTest.java | 2 ++ .../ejb/test/transaction/FlushAndTransactionTest.java | 1 + 5 files changed, 8 insertions(+) diff --git a/entitymanager/src/test/java/org/hibernate/ejb/test/callbacks/CallbacksTest.java b/entitymanager/src/test/java/org/hibernate/ejb/test/callbacks/CallbacksTest.java index 651fff3b21..e7b12d47c6 100644 --- a/entitymanager/src/test/java/org/hibernate/ejb/test/callbacks/CallbacksTest.java +++ b/entitymanager/src/test/java/org/hibernate/ejb/test/callbacks/CallbacksTest.java @@ -116,6 +116,7 @@ public class CallbacksTest extends TestCase { em.flush(); assertNotNull( rc.getCreationDate() ); em.getTransaction().rollback(); + em.close(); } public void testCallBackListenersHierarchy() throws Exception { diff --git a/entitymanager/src/test/java/org/hibernate/ejb/test/emops/FlushTest.java b/entitymanager/src/test/java/org/hibernate/ejb/test/emops/FlushTest.java index 6ffd3e6dc3..35cf832612 100644 --- a/entitymanager/src/test/java/org/hibernate/ejb/test/emops/FlushTest.java +++ b/entitymanager/src/test/java/org/hibernate/ejb/test/emops/FlushTest.java @@ -66,6 +66,9 @@ public class FlushTest extends TestCase { for (Decorate value : founds) { assertTrue( names.contains( value.getPet().getName() ) ); } + manager.getTransaction().rollback(); + + manager.close(); } diff --git a/entitymanager/src/test/java/org/hibernate/ejb/test/exception/ExceptionTest.java b/entitymanager/src/test/java/org/hibernate/ejb/test/exception/ExceptionTest.java index b643590a7d..8179311d11 100644 --- a/entitymanager/src/test/java/org/hibernate/ejb/test/exception/ExceptionTest.java +++ b/entitymanager/src/test/java/org/hibernate/ejb/test/exception/ExceptionTest.java @@ -99,6 +99,7 @@ public class ExceptionTest extends TestCase { catch( PersistenceException e ) { Throwable t = e.getCause(); assertTrue("Should be a constraint violation", t instanceof ConstraintViolationException); + em.getTransaction().rollback(); } finally { em.close(); diff --git a/entitymanager/src/test/java/org/hibernate/ejb/test/lock/LockTest.java b/entitymanager/src/test/java/org/hibernate/ejb/test/lock/LockTest.java index d00e1636ea..9810681746 100644 --- a/entitymanager/src/test/java/org/hibernate/ejb/test/lock/LockTest.java +++ b/entitymanager/src/test/java/org/hibernate/ejb/test/lock/LockTest.java @@ -30,6 +30,8 @@ public class LockTest extends TestCase { assertEquals( "surname", lock.getName() ); em.remove( lock ); em.getTransaction().commit(); + + em.close(); } public void testLockWrite() throws Exception { diff --git a/entitymanager/src/test/java/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java b/entitymanager/src/test/java/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java index 6fab551f14..42c0dbd77e 100644 --- a/entitymanager/src/test/java/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java +++ b/entitymanager/src/test/java/org/hibernate/ejb/test/transaction/FlushAndTransactionTest.java @@ -42,6 +42,7 @@ public class FlushAndTransactionTest extends TestCase { em.getTransaction().begin(); em.remove( em.find( Book.class, book.id ) ); em.getTransaction().commit(); + em.close(); } // public void testTransactionalOperationsWhenTransactional() throws Exception {