From 4b7da02b66acbbebe85fba6ccb49221fe758631c Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Mon, 18 Apr 2016 11:30:22 +0100 Subject: [PATCH] HHH-10693 - Change test to run with PostgreSQL dialect (cherry picked from commit c1023ac49e4712826b8c09d319d9c4e9154983b5) --- .../nationalized/StringNationalizedTest.java | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/nationalized/StringNationalizedTest.java b/hibernate-core/src/test/java/org/hibernate/test/nationalized/StringNationalizedTest.java index 80700b7fd1..a82753233d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/nationalized/StringNationalizedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/nationalized/StringNationalizedTest.java @@ -10,22 +10,30 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; +import java.util.List; +import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.annotations.Nationalized; import org.hibernate.dialect.Oracle10gDialect; +import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.resource.transaction.spi.TransactionStatus; +import org.junit.After; +import org.junit.Test; + import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; -import org.junit.Test; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; /** * @author Andrea Boriero */ @TestForIssue(jiraKey = "10495") -@RequiresDialect(value = Oracle10gDialect.class) +@RequiresDialect(value = {Oracle10gDialect.class, PostgreSQL81Dialect.class}) public class StringNationalizedTest extends BaseCoreFunctionalTestCase { @Override @@ -33,6 +41,26 @@ public class StringNationalizedTest extends BaseCoreFunctionalTestCase { return new Class[] {NationalizedEntity.class}; } + @After + public void tearDown() { + Session s = openSession(); + s.getTransaction().begin(); + try { + final Query query = s.createQuery( "delete from NationalizedEntity" ); + query.executeUpdate(); + s.getTransaction().commit(); + } + catch (RuntimeException e) { + if ( s.getTransaction().getStatus() == TransactionStatus.ACTIVE ) { + s.getTransaction().rollback(); + } + throw e; + } + finally { + s.close(); + } + } + @Test public void testSaveEntityWithNationalizedProperty() { Session s = openSession(); @@ -52,6 +80,17 @@ public class StringNationalizedTest extends BaseCoreFunctionalTestCase { finally { s.close(); } + + s = openSession(); + try { + final Query query = s.createQuery( "from NationalizedEntity where name = :name" ); + query.setString( "name", "Hello" ); + final List list = query.list(); + assertThat( list.size(), is( 1 ) ); + } + finally { + s.close(); + } } @Entity(name = "NationalizedEntity")