LockTest changes: better handling of unexpected exception and don't call commit after timing out

This commit is contained in:
Scott Marlow 2011-10-26 22:45:28 -04:00
parent 3c11500618
commit e044cb2ce1
1 changed files with 9 additions and 4 deletions

View File

@ -29,6 +29,8 @@ import javax.persistence.LockTimeoutException;
import javax.persistence.OptimisticLockException; import javax.persistence.OptimisticLockException;
import javax.persistence.Query; import javax.persistence.Query;
import javax.persistence.QueryTimeoutException; import javax.persistence.QueryTimeoutException;
import java.lang.RuntimeException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -388,9 +390,12 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase {
// success // success
log.info("testContendedPessimisticReadLockTimeout: (BG) got expected timeout exception"); log.info("testContendedPessimisticReadLockTimeout: (BG) got expected timeout exception");
timedOut = true; timedOut = true;
em2.getTransaction().rollback();
return new Boolean(timedOut);
} }
catch ( Throwable e) { catch ( Throwable e) {
log.info("Expected LockTimeoutException but got unexpected exception", e); log.info("Expected LockTimeoutException but got unexpected exception", e);
throw new RuntimeException("Expected LockTimeoutException but got unexpected exception",e);
} }
em2.getTransaction().commit(); em2.getTransaction().commit();
return new Boolean(timedOut); return new Boolean(timedOut);