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