HHH-10635 - Add test for issue

(cherry picked from commit e8dec1a062)
This commit is contained in:
Andrea Boriero 2016-03-30 12:45:11 +02:00 committed by Gail Badner
parent c57c564fa5
commit f34b035f6c
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 );
}
}
}