HHH-10375 - Add test for issue

(cherry picked from commit 6e47c2840a)
This commit is contained in:
Andrea Boriero 2016-04-19 21:01:45 +01:00 committed by Gail Badner
parent b57bbdabf6
commit cf665a3e84
1 changed files with 21 additions and 0 deletions

View File

@ -23,13 +23,16 @@ import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
/** /**
@ -155,6 +158,24 @@ public class ListAddTest extends BaseNonConfigCoreFunctionalTestCase {
session.close(); 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" ) @Entity( name = "Question" )
@Table( name = "Question" ) @Table( name = "Question" )