HHH-7347 fail test if it runs longer than 30 minutes to prevent hangs

This commit is contained in:
Strong Liu 2012-05-23 22:11:46 +08:00
parent 7ed323a51f
commit 4b74517dcd
1 changed files with 5 additions and 0 deletions

View File

@ -27,6 +27,9 @@ import javax.transaction.SystemException;
import org.jboss.logging.Logger;
import org.junit.After;
import org.junit.Rule;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.junit.runner.RunWith;
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
@ -41,6 +44,8 @@ import org.hibernate.testing.jta.TestingJtaPlatformImpl;
public abstract class BaseUnitTestCase {
private static final Logger log = Logger.getLogger( BaseUnitTestCase.class );
@Rule
public TestRule globalTimeout= new Timeout(30 * 60 * 1000); // no test should run longer than 30 minutes
@After
public void releaseTransactions() {
if ( JtaStatusHelper.isActive( TestingJtaPlatformImpl.INSTANCE.getTransactionManager() ) ) {