HHH-11434 - prevent failures in some tests from freezing the whole test suite

This commit is contained in:
Jan Martiska 2017-01-30 15:32:48 +00:00 committed by Andrea Boriero
parent ec9e8dbdfa
commit e62d71b76b
2 changed files with 12 additions and 19 deletions

View File

@ -16,6 +16,7 @@ import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.hamcrest.core.Is.is;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertThat;
/**
@ -32,25 +33,18 @@ public class FilterInheritanceTest extends BaseCoreFunctionalTestCase {
@Override
protected void prepareTest() throws Exception {
openSession();
session.beginTransaction();
persistTestData();
session.getTransaction().commit();
session.close();
doInHibernate( this::sessionFactory, session -> {
persistTestData();
});
}
@Override
protected void cleanupTest() throws Exception {
super.cleanupTest();
openSession();
session.beginTransaction();
session.createQuery( "delete from Human" ).executeUpdate();
session.createQuery( "delete from Mammal" ).executeUpdate();
session.getTransaction().commit();
session.close();
doInHibernate( this::sessionFactory, session -> {
session.createQuery("delete from Human").executeUpdate();
session.createQuery("delete from Mammal").executeUpdate();
});
}
protected void persistTestData() {

View File

@ -52,6 +52,7 @@ import org.hibernate.testing.BeforeClassOnce;
import org.hibernate.testing.OnExpectedFailure;
import org.hibernate.testing.OnFailure;
import org.hibernate.testing.cache.CachingRegionFactory;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import org.junit.After;
import org.junit.Before;
@ -481,11 +482,9 @@ public class BaseNonConfigCoreFunctionalTestCase extends BaseUnitTestCase {
}
protected void cleanupTestData() throws Exception {
Session s = openSession();
s.beginTransaction();
s.createQuery( "delete from java.lang.Object" ).executeUpdate();
s.getTransaction().commit();
s.close();
doInHibernate(this::sessionFactory, s -> {
s.createQuery("delete from java.lang.Object").executeUpdate();
});
}