From 6e47c2840aa8410cac44b320161e8fac1a771756 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 19 Apr 2016 21:01:45 +0100 Subject: [PATCH] HHH-10375 - Add test for issue --- .../delayedOperation/ListAddTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/hibernate-core/src/test/java/org/hibernate/test/collection/delayedOperation/ListAddTest.java b/hibernate-core/src/test/java/org/hibernate/test/collection/delayedOperation/ListAddTest.java index 4b38ec630a..1bbb060894 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/collection/delayedOperation/ListAddTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/collection/delayedOperation/ListAddTest.java @@ -23,13 +23,16 @@ import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.collection.spi.PersistentCollection; +import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; import org.junit.After; import org.junit.Before; import org.junit.Test; +import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; /** @@ -155,6 +158,24 @@ public class ListAddTest extends BaseNonConfigCoreFunctionalTestCase { session.close(); } + @Test + @TestForIssue( jiraKey = "HHH-10375") + public void testAddQuestionAfterSessionIsClosed(){ + Session session = openSession(); + Transaction transaction = session.beginTransaction(); + + Quizz quizz = session.get( Quizz.class, 1 ); + assertThat( "expected 4 questions", quizz.getQuestions().size(), is(3) ); + transaction.commit(); + session.close(); + + quizz.addQuestion( new Question( 4, "question 4" ) ); + assertThat( "expected 4 questions", quizz.getQuestions().size(), is(4) ); + + quizz.addQuestion( 1, new Question( 5, "question 5" ) ); + assertThat( "expected 5 questions", quizz.getQuestions().size(), is(5) ); + } + @Entity( name = "Question" ) @Table( name = "Question" )