HHH-18806 Use JUnit Jupiter API to make feature check effective

This commit is contained in:
Christian Beikov 2024-12-17 17:51:07 +01:00
parent 46b3b3a2d2
commit 6f887a516a
1 changed files with 8 additions and 14 deletions
hibernate-core/src/test/java/org/hibernate/orm/test/mapping/basic

View File

@ -8,31 +8,25 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import org.hibernate.annotations.Nationalized;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
import static org.junit.Assert.assertEquals;
/**
* @author Vlad Mihalcea
*/
@Jpa(annotatedClasses = NationalizedTest.Product.class)
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsUnicodeNClob.class)
public class NationalizedTest extends BaseEntityManagerFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Product.class
};
}
public class NationalizedTest {
@Test
public void test() {
Integer productId = doInJPA(this::entityManagerFactory, entityManager -> {
public void test(EntityManagerFactoryScope scope) {
Integer productId = scope.fromTransaction( entityManager -> {
//tag::basic-nationalized-persist-example[]
final Product product = new Product();
product.setId(1);
@ -44,7 +38,7 @@ public class NationalizedTest extends BaseEntityManagerFunctionalTestCase {
return product.getId();
});
doInJPA(this::entityManagerFactory, entityManager -> {
scope.inTransaction( entityManager -> {
Product product = entityManager.find(Product.class, productId);
assertEquals("My product®™ warranty 😍", product.getWarranty());