HHH-10693 - Change test to run with PostgreSQL dialect

(cherry picked from commit c1023ac49e)
This commit is contained in:
Andrea Boriero 2016-04-18 11:30:22 +01:00 committed by Gail Badner
parent f75798518a
commit 4b7da02b66
1 changed files with 41 additions and 2 deletions

View File

@ -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")