HHH-12034 - Fix tests hanging on PostgrSQL

This commit is contained in:
Andrea Boriero 2017-10-16 20:58:23 +01:00
parent 07eec26d67
commit 61ee2d2232
1 changed files with 34 additions and 34 deletions

View File

@ -182,23 +182,23 @@ public class GetLoadTest extends BaseEntityManagerFunctionalTestCase {
@FailureExpected( jiraKey = "HHH-12034" )
public void testLoadIdNotFound_FieldBasedAccess() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
Session s = ( Session ) em.getDelegate();
assertNull( s.get( Workload.class, 999 ) );
Workload proxy = s.load( Workload.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
try {
em.getTransaction().begin();
Session s = (Session) em.getDelegate();
assertNull( s.get( Workload.class, 999 ) );
Workload proxy = s.load( Workload.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
proxy.getId();
fail( "Should have failed because there is no Workload Entity with id == 999" );
}
catch (EntityNotFoundException ex) {
// expected
em.getTransaction().rollback();
}
finally {
em.getTransaction().rollback();
em.close();
}
}
@ -208,22 +208,22 @@ public class GetLoadTest extends BaseEntityManagerFunctionalTestCase {
@FailureExpected( jiraKey = "HHH-12034" )
public void testReferenceIdNotFound_FieldBasedAccess() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
assertNull( em.find( Workload.class, 999 ) );
Workload proxy = em.getReference( Workload.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
try {
em.getTransaction().begin();
assertNull( em.find( Workload.class, 999 ) );
Workload proxy = em.getReference( Workload.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
proxy.getId();
fail( "Should have failed because there is no Workload Entity with id == 999" );
}
catch (EntityNotFoundException ex) {
// expected
em.getTransaction().rollback();
}
finally {
em.getTransaction().rollback();
em.close();
}
}
@ -233,23 +233,23 @@ public class GetLoadTest extends BaseEntityManagerFunctionalTestCase {
@FailureExpected( jiraKey = "HHH-12034" )
public void testLoadIdNotFound_PropertyBasedAccess() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
Session s = ( Session ) em.getDelegate();
assertNull( s.get( Employee.class, 999 ) );
Employee proxy = s.load( Employee.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
try {
em.getTransaction().begin();
Session s = (Session) em.getDelegate();
assertNull( s.get( Employee.class, 999 ) );
Employee proxy = s.load( Employee.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
proxy.getId();
fail( "Should have failed because there is no Employee Entity with id == 999" );
}
catch (EntityNotFoundException ex) {
// expected
em.getTransaction().rollback();
}
finally {
em.getTransaction().rollback();
em.close();
}
}
@ -259,22 +259,22 @@ public class GetLoadTest extends BaseEntityManagerFunctionalTestCase {
@FailureExpected( jiraKey = "HHH-12034" )
public void testReferenceIdNotFound_PropertyBasedAccess() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
assertNull( em.find( Employee.class, 999 ) );
Employee proxy = em.getReference( Employee.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
try {
em.getTransaction().begin();
assertNull( em.find( Employee.class, 999 ) );
Employee proxy = em.getReference( Employee.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
proxy.getId();
fail( "Should have failed because there is no Employee Entity with id == 999" );
}
catch (EntityNotFoundException ex) {
// expected
em.getTransaction().rollback();
}
finally {
em.getTransaction().rollback();
em.close();
}
}