HHH-11434 - prevent failures in some tests from freezing the whole test suite
(cherry picked from commit 8f6e4d5675
)
This commit is contained in:
parent
71034a99fd
commit
4c16fd69c7
|
@ -34,53 +34,36 @@ 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();
|
Mammal mammal = new Mammal();
|
||||||
});
|
mammal.setName( "unimportant" );
|
||||||
|
session.persist( mammal );
|
||||||
|
|
||||||
|
Human human = new Human();
|
||||||
|
human.setName( "unimportant" );
|
||||||
|
session.persist( human );
|
||||||
|
|
||||||
|
Human human1 = new Human();
|
||||||
|
human1.setName( "unimportant_1" );
|
||||||
|
session.persist( human1 );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cleanupTest() throws Exception {
|
protected boolean isCleanupTestDataRequired() {
|
||||||
super.cleanupTest();
|
return true;
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
|
||||||
session.createQuery("delete from Human").executeUpdate();
|
|
||||||
session.createQuery("delete from Mammal").executeUpdate();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void persistTestData() {
|
|
||||||
Mammal mammal = new Mammal();
|
|
||||||
mammal.setName( "unimportant" );
|
|
||||||
session.persist( mammal );
|
|
||||||
|
|
||||||
Human human = new Human();
|
|
||||||
human.setName( "unimportant" );
|
|
||||||
session.persist( human );
|
|
||||||
|
|
||||||
Human human1 = new Human();
|
|
||||||
human1.setName( "unimportant_1" );
|
|
||||||
session.persist( human1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue