Skip to content

Commit 9be8b26

Browse files
committed
HHH-19846 - Drop JUnit 4 usage
Not converted... * org.hibernate.orm.test.hql.PostgreSQLFunctionSelectClauseTest - registering custom function * org.hibernate.orm.test.hql.PostgreSQLFunctionWhereClauseTest - aux-db-object * org.hibernate.orm.test.id.usertype - type registrations * org.hibernate.orm.test.idgen.enhanced.HiloOptimizerConcurrencyTest - recreation of SF during tests * org.hibernate.orm.test.type.AbstractJavaTimeTypeTest subtypes - crazy parameterization (see org.hibernate.orm.test.tm.InterceptorTransactionTest) * org.hibernate.orm.test.cdi.general.hibernatesearch.extended.HibernateSearchExtendedCdiSupportTest - not sure yet, all the other tests here pass with conversion - shelved for now
1 parent 0421b6f commit 9be8b26

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import jakarta.persistence.Table;
2222
import org.hamcrest.MatcherAssert;
2323
import org.hibernate.boot.model.naming.Identifier;
24+
import org.hibernate.boot.registry.StandardServiceRegistry;
25+
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
2426
import org.hibernate.community.dialect.TiDBDialect;
2527
import org.hibernate.dialect.SQLServerDialect;
2628
import org.hibernate.dialect.SybaseDialect;
@@ -57,6 +59,8 @@
5759
import java.util.TreeMap;
5860

5961
import static org.hamcrest.core.Is.is;
62+
import static org.hibernate.cfg.MappingSettings.KEYWORD_AUTO_QUOTING_ENABLED;
63+
import static org.hibernate.cfg.SchemaToolingSettings.HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY;
6064

6165
/**
6266
* @author Andrea Boriero
@@ -98,6 +102,13 @@ public SchemaUpdateTest(
98102
this.output = new File( outputDir, "update_script.sql" );
99103
}
100104

105+
@Override
106+
public StandardServiceRegistry produceServiceRegistry(StandardServiceRegistryBuilder builder) {
107+
return builder.applySetting( KEYWORD_AUTO_QUOTING_ENABLED, true )
108+
.applySetting( HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY, jdbcMetadataExtractorStrategy )
109+
.build();
110+
}
111+
101112
@BeforeEach
102113
void prepare(ServiceRegistryScope registryScope) {
103114
// Databases that use case-insensitive quoted identifiers need to be skipped.
@@ -192,6 +203,7 @@ public static class UppercaseTableNameEntity {
192203
MixedCaseTableNameEntity mixedCaseTableNameEntity;
193204
}
194205

206+
@SuppressWarnings("unused")
195207
@Entity(name = "TestEntity3")
196208
@Table(name = "`TESTentity`", indexes = {@Index(name = "index1", columnList = "`FieLd1`"), @Index(name = "Index2", columnList = "`FIELD_2`")})
197209
public static class MixedCaseTableNameEntity {
@@ -210,6 +222,7 @@ public static class MixedCaseTableNameEntity {
210222
private Set<Match> matches = new HashSet<>();
211223
}
212224

225+
@SuppressWarnings("unused")
213226
@Entity(name = "Match")
214227
public static class Match {
215228
@Id

hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateWithViewsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
@Setting(name = DEFAULT_SCHEMA, value = "public")
4141
})
4242
@DomainModel(annotatedClasses = SchemaUpdateWithViewsTest.MyEntity.class)
43-
@SessionFactory
43+
@SessionFactory(exportSchema = false)
4444
public class SchemaUpdateWithViewsTest {
4545
@Test
4646
public void testUpdateSchema(DomainModelScope modelScope) {

hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SqlServerQuoteSchemaTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.io.File;
3030
import java.io.IOException;
3131
import java.nio.file.Files;
32+
import java.sql.SQLException;
3233
import java.util.EnumSet;
3334
import java.util.regex.Matcher;
3435
import java.util.regex.Pattern;
@@ -50,8 +51,16 @@ public class SqlServerQuoteSchemaTest {
5051
void setUp(SessionFactoryScope factoryScope) {
5152
factoryScope.inTransaction( (session) -> session.doWork( (connection) -> {
5253
try (var statement = connection.createStatement()) {
53-
statement.execute( "DROP TABLE [my-schema].my_entity" );
54-
statement.execute( "DROP SCHEMA [my-schema]" );
54+
try {
55+
statement.execute( "DROP TABLE [my-schema].my_entity" );
56+
}
57+
catch (SQLException ignore) {
58+
}
59+
try {
60+
statement.execute( "DROP SCHEMA [my-schema]" );
61+
}
62+
catch (SQLException ignore) {
63+
}
5564
statement.execute( "CREATE SCHEMA [my-schema]" );
5665
}
5766
} ) );
@@ -61,8 +70,11 @@ void setUp(SessionFactoryScope factoryScope) {
6170
void tearDown(SessionFactoryScope factoryScope) {
6271
factoryScope.inTransaction( (session) -> session.doWork( (connection) -> {
6372
try (var statement = connection.createStatement()) {
73+
statement.execute( "DROP TABLE [my-schema].my_entity" );
6474
statement.execute( "DROP SCHEMA [my-schema]" );
6575
}
76+
catch (SQLException ignore) {
77+
}
6678
} ) );
6779
}
6880

0 commit comments

Comments
 (0)