HHH-17739 add tests

This commit is contained in:
Gavin King 2024-09-08 22:12:31 +02:00
parent 6c6c92e88d
commit 349b209deb
2 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,36 @@
package org.hibernate.orm.test.annotations.basic;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import org.hibernate.MappingException;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@JiraKey("HHH-17739")
@Jpa(annotatedClasses = ListOfByteArrayTest.Broken.class)
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsStandardArrays.class)
public class ListOfByteArrayTest {
@Test void test(EntityManagerFactoryScope scope) {
try {
scope.getEntityManagerFactory();
fail();
}
catch (MappingException e) {
assertTrue( e.getMessage().contains("binaryList") );
}
}
@Entity
static class Broken {
@Id long id;
List<byte[]> binaryList; // this is not supported
}
}

View File

@ -0,0 +1,41 @@
package org.hibernate.orm.test.annotations.basic;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
@JiraKey("HHH-17739")
@Jpa(annotatedClasses = ListOfStringTest.Unbroken.class)
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsStandardArrays.class)
public class ListOfStringTest {
@Test void test(EntityManagerFactoryScope scope) {
scope.inTransaction(entityManager -> {
entityManager.persist( new Unbroken( List.of("hello", "world") ) );
});
scope.inTransaction(entityManager -> {
assertEquals( List.of("hello", "world"),
entityManager.find(Unbroken.class, 0).stringList );
});
}
@Entity
static class Unbroken {
@Id long id;
List<String> stringList; // this should be OK
Unbroken(List<String> stringList) {
this.stringList = stringList;
}
Unbroken() {
}
}
}