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

This commit is contained in:
Andrea Boriero 2017-02-01 09:31:44 +00:00
parent e62d71b76b
commit 8f6e4d5675
1 changed files with 20 additions and 37 deletions

View File

@ -34,20 +34,6 @@ public class FilterInheritanceTest extends BaseCoreFunctionalTestCase {
@Override @Override
protected void prepareTest() throws Exception { protected void prepareTest() throws Exception {
doInHibernate( this::sessionFactory, session -> { doInHibernate( this::sessionFactory, session -> {
persistTestData();
});
}
@Override
protected void cleanupTest() throws Exception {
super.cleanupTest();
doInHibernate( this::sessionFactory, session -> {
session.createQuery("delete from Human").executeUpdate();
session.createQuery("delete from Mammal").executeUpdate();
});
}
protected void persistTestData() {
Mammal mammal = new Mammal(); Mammal mammal = new Mammal();
mammal.setName( "unimportant" ); mammal.setName( "unimportant" );
session.persist( mammal ); session.persist( mammal );
@ -59,28 +45,25 @@ public class FilterInheritanceTest extends BaseCoreFunctionalTestCase {
Human human1 = new Human(); Human human1 = new Human();
human1.setName( "unimportant_1" ); human1.setName( "unimportant_1" );
session.persist( human1 ); session.persist( human1 );
} );
}
@Override
protected boolean isCleanupTestDataRequired() {
return true;
} }
@Test @Test
@TestForIssue(jiraKey = "HHH-8895") @TestForIssue(jiraKey = "HHH-8895")
public void testSlectFromHuman() throws Exception { public void testSelectFromHuman() throws Exception {
openSession(); doInHibernate( this::sessionFactory, session -> {
session.enableFilter( "nameFilter" ).setParameter( "name", "unimportant" ); session.enableFilter( "nameFilter" ).setParameter( "name", "unimportant" );
try {
transaction = session.beginTransaction();
List humans = session.createQuery( "SELECT h FROM Human h" ).list(); List humans = session.createQuery( "SELECT h FROM Human h" ).list();
assertThat( humans.size(), is( 1 ) ); assertThat( humans.size(), is( 1 ) );
Human human = (Human) humans.get( 0 ); Human human = (Human) humans.get( 0 );
assertThat(human.getName(), is("unimportant")); assertThat( human.getName(), is( "unimportant" ) );
} );
transaction.commit();
}
catch (Exception e) {
if ( transaction != null ) {
transaction.rollback();
}
throw e;
}
} }
} }