HHH-10635 - Add test for issue

This commit is contained in:
Andrea Boriero 2016-03-30 12:45:11 +02:00
parent a0d6412ca6
commit e8dec1a062
1 changed files with 16 additions and 0 deletions

View File

@ -28,6 +28,7 @@ import org.junit.Test;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Environment;
import org.hibernate.ejb.AvailableSettings;
import org.hibernate.ejb.HibernateEntityManager;
@ -461,4 +462,19 @@ public class EntityManagerTest extends BaseEntityManagerFunctionalTestCase {
}
}
@Test
@TestForIssue( jiraKey = "HHH-10635")
public void testEntityManagerIsClosedAfterClosingTheUnwrappedSession() {
EntityManager em = getOrCreateEntityManager();
Session session = em.unwrap( Session.class );
session.close();
assertEquals( false, em.isOpen() );
try {
em.close();
fail( "The EntityManager should be closed" );
}
catch (Exception e) {
assertTrue( e instanceof IllegalStateException );
}
}
}