diff --git a/hibernate-core/src/test/java/org/hibernate/test/flush/TestFlushJoinTransaction.java b/hibernate-core/src/test/java/org/hibernate/test/flush/TestFlushJoinTransaction.java index c1aea28d56..c615974f76 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/flush/TestFlushJoinTransaction.java +++ b/hibernate-core/src/test/java/org/hibernate/test/flush/TestFlushJoinTransaction.java @@ -12,7 +12,6 @@ import javax.persistence.TransactionRequiredException; import org.hibernate.Session; import org.hibernate.cfg.AvailableSettings; -import org.junit.Assert; import org.junit.Test; import org.hibernate.testing.TestForIssue; @@ -20,6 +19,8 @@ import org.hibernate.testing.jta.TestingJtaBootstrap; import org.hibernate.testing.jta.TestingJtaPlatformImpl; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; +import static org.junit.Assert.fail; + /** * @author Michiel Hendriks */ @@ -42,7 +43,7 @@ public class TestFlushJoinTransaction extends BaseNonConfigCoreFunctionalTestCas TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit(); } catch (TransactionRequiredException e) { - Assert.fail("No TransactionRequiredException expected."); + fail("No TransactionRequiredException expected."); } finally { session.close(); @@ -59,7 +60,23 @@ public class TestFlushJoinTransaction extends BaseNonConfigCoreFunctionalTestCas TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit(); } catch (TransactionRequiredException e) { - Assert.fail("No TransactionRequiredException expected."); + fail("No TransactionRequiredException expected."); + } + finally { + session.close(); + } + } + + @Test + public void testIsConnectedFlushShouldThrowExceptionIfNoTransaction() { + Session session = openSession(); + try { + session.isConnected(); + session.flush(); + fail("A TransactionRequiredException should be thrown"); + } + catch (TransactionRequiredException e) { + //expected } finally { session.close();