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

View File

@ -182,6 +182,7 @@ public void testLoadGetId() {
@FailureExpected( jiraKey = "HHH-12034" )
public void testLoadIdNotFound_FieldBasedAccess() {
EntityManager em = getOrCreateEntityManager();
try {
em.getTransaction().begin();
Session s = (Session) em.getDelegate();
@ -190,15 +191,14 @@ public void testLoadIdNotFound_FieldBasedAccess() {
Workload proxy = s.load( Workload.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
try {
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,6 +208,7 @@ public void testLoadIdNotFound_FieldBasedAccess() {
@FailureExpected( jiraKey = "HHH-12034" )
public void testReferenceIdNotFound_FieldBasedAccess() {
EntityManager em = getOrCreateEntityManager();
try {
em.getTransaction().begin();
assertNull( em.find( Workload.class, 999 ) );
@ -215,15 +216,14 @@ public void testReferenceIdNotFound_FieldBasedAccess() {
Workload proxy = em.getReference( Workload.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
try {
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,6 +233,7 @@ public void testReferenceIdNotFound_FieldBasedAccess() {
@FailureExpected( jiraKey = "HHH-12034" )
public void testLoadIdNotFound_PropertyBasedAccess() {
EntityManager em = getOrCreateEntityManager();
try {
em.getTransaction().begin();
Session s = (Session) em.getDelegate();
@ -241,15 +242,14 @@ public void testLoadIdNotFound_PropertyBasedAccess() {
Employee proxy = s.load( Employee.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
try {
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,6 +259,7 @@ public void testLoadIdNotFound_PropertyBasedAccess() {
@FailureExpected( jiraKey = "HHH-12034" )
public void testReferenceIdNotFound_PropertyBasedAccess() {
EntityManager em = getOrCreateEntityManager();
try {
em.getTransaction().begin();
assertNull( em.find( Employee.class, 999 ) );
@ -266,15 +267,14 @@ public void testReferenceIdNotFound_PropertyBasedAccess() {
Employee proxy = em.getReference( Employee.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
try {
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();
}
}