Skip to content

Commit ec2204a

Browse files
committed
HHH-19916 More drop JUnit 4 usage work
1 parent b635806 commit ec2204a

File tree

8 files changed

+52
-56
lines changed

8 files changed

+52
-56
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/uniqueconstraint/UniqueConstraintBatchingTest.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,20 @@
44
*/
55
package org.hibernate.orm.test.annotations.uniqueconstraint;
66

7+
import jakarta.persistence.PersistenceException;
78
import org.hibernate.cfg.AvailableSettings;
89
import org.hibernate.dialect.H2Dialect;
910
import org.hibernate.engine.jdbc.spi.SQLExceptionLogging;
10-
11-
import org.hibernate.testing.orm.junit.JiraKey;
12-
import org.hibernate.testing.logger.LoggerInspectionRule;
1311
import org.hibernate.testing.logger.Triggerable;
1412
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
13+
import org.hibernate.testing.orm.junit.JiraKey;
1514
import org.hibernate.testing.orm.junit.Jpa;
1615
import org.hibernate.testing.orm.junit.RequiresDialect;
1716
import org.hibernate.testing.orm.junit.Setting;
18-
import org.junit.Rule;
17+
import org.hibernate.testing.orm.logger.LoggerInspectionExtension;
1918
import org.junit.jupiter.api.BeforeEach;
2019
import org.junit.jupiter.api.Test;
21-
22-
23-
import jakarta.persistence.PersistenceException;
24-
20+
import org.junit.jupiter.api.extension.RegisterExtension;
2521

2622
import static org.junit.jupiter.api.Assertions.assertEquals;
2723
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -42,9 +38,9 @@
4238
integrationSettings = @Setting(name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "5")
4339
)
4440
public class UniqueConstraintBatchingTest {
45-
46-
@Rule
47-
public LoggerInspectionRule logInspection = new LoggerInspectionRule( SQLExceptionLogging.ERROR_LOG );
41+
@RegisterExtension
42+
public LoggerInspectionExtension logInspection =
43+
LoggerInspectionExtension.builder().setLogger( SQLExceptionLogging.ERROR_LOG ).build();
4844

4945
private Triggerable triggerable;
5046

hibernate-core/src/test/java/org/hibernate/orm/test/id/hhh12973/PostgreSQLSequenceGeneratorWithSerialTest.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,36 @@
44
*/
55
package org.hibernate.orm.test.id.hhh12973;
66

7-
import java.io.StringReader;
8-
import java.sql.Statement;
9-
import java.util.Map;
10-
import java.util.concurrent.atomic.AtomicLong;
117
import jakarta.persistence.Entity;
128
import jakarta.persistence.EntityManagerFactory;
139
import jakarta.persistence.GeneratedValue;
1410
import jakarta.persistence.GenerationType;
1511
import jakarta.persistence.Id;
1612
import jakarta.persistence.Table;
17-
1813
import org.hibernate.Session;
1914
import org.hibernate.SessionFactory;
2015
import org.hibernate.boot.registry.StandardServiceRegistry;
2116
import org.hibernate.cfg.AvailableSettings;
2217
import org.hibernate.cfg.Configuration;
2318
import org.hibernate.dialect.PostgreSQLDialect;
2419
import org.hibernate.id.SequenceMismatchStrategy;
25-
26-
import org.hibernate.testing.orm.junit.JiraKey;
27-
import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest;
28-
import org.hibernate.testing.logger.LoggerInspectionRule;
2920
import org.hibernate.testing.logger.Triggerable;
21+
import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest;
22+
import org.hibernate.testing.orm.junit.JiraKey;
3023
import org.hibernate.testing.orm.junit.RequiresDialect;
24+
import org.hibernate.testing.orm.logger.LoggerInspectionExtension;
3125
import org.hibernate.testing.util.ServiceRegistryUtil;
32-
import org.junit.Rule;
3326
import org.junit.jupiter.api.Test;
27+
import org.junit.jupiter.api.extension.RegisterExtension;
3428

29+
import java.io.StringReader;
30+
import java.sql.Statement;
31+
import java.util.Map;
32+
import java.util.concurrent.atomic.AtomicLong;
3533

34+
import static org.assertj.core.api.Assertions.assertThat;
3635
import static org.hibernate.id.enhanced.SequenceGeneratorLogger.SEQUENCE_GENERATOR_LOGGER;
3736
import static org.junit.jupiter.api.Assertions.assertEquals;
38-
import static org.junit.jupiter.api.Assertions.assertFalse;
3937

4038
/**
4139
* @author Vlad Mihalcea
@@ -44,10 +42,11 @@
4442
@RequiresDialect(value = PostgreSQLDialect.class)
4543
public class PostgreSQLSequenceGeneratorWithSerialTest extends EntityManagerFactoryBasedFunctionalTest {
4644

47-
@Rule
48-
public LoggerInspectionRule logInspection = new LoggerInspectionRule( SEQUENCE_GENERATOR_LOGGER );
45+
@RegisterExtension
46+
public LoggerInspectionExtension logInspection =
47+
LoggerInspectionExtension.builder().setLogger( SEQUENCE_GENERATOR_LOGGER ).build();
4948

50-
private final Triggerable triggerable = logInspection.watchForLogMessages( "HHH090203:" );
49+
public final Triggerable triggerable = logInspection.watchForLogMessages( "HHH090203:" );
5150

5251
@Override
5352
protected Class<?>[] getAnnotatedClasses() {
@@ -63,7 +62,7 @@ protected Class<?>[] getAnnotatedClasses() {
6362
@Override
6463
protected void addConfigOptions(Map settings) {
6564
triggerable.reset();
66-
assertFalse( triggerable.wasTriggered() );
65+
assertThat( triggerable.wasTriggered() ).isFalse();
6766

6867
//For this test, we need to make sure the DB is created prior to bootstrapping Hibernate
6968
StandardServiceRegistry ssr = ServiceRegistryUtil.serviceRegistry();
@@ -105,7 +104,7 @@ protected boolean exportSchema() {
105104
@Override
106105
protected void entityManagerFactoryBuilt(EntityManagerFactory factory) {
107106
// this message is logged at trace level
108-
assertFalse( triggerable.wasTriggered() );
107+
assertThat( triggerable.wasTriggered() ).isFalse();
109108
}
110109

111110
@Test

hibernate-core/src/test/java/org/hibernate/orm/test/id/hhh12973/SequenceMismatchStrategyFixWithSequenceGeneratorTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919
import org.hibernate.boot.spi.MetadataImplementor;
2020
import org.hibernate.cfg.AvailableSettings;
2121
import org.hibernate.service.ServiceRegistry;
22+
import org.hibernate.testing.orm.logger.LoggerInspectionExtension;
2223
import org.hibernate.tool.hbm2ddl.SchemaExport;
2324
import org.hibernate.tool.schema.TargetType;
2425

2526
import org.hibernate.testing.orm.junit.JiraKey;
2627
import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest;
27-
import org.hibernate.testing.logger.LoggerInspectionRule;
2828
import org.hibernate.testing.logger.Triggerable;
2929
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
3030
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
3131
import org.hibernate.testing.util.ServiceRegistryUtil;
32-
import org.junit.Rule;
3332
import org.junit.jupiter.api.AfterAll;
3433
import org.junit.jupiter.api.Test;
34+
import org.junit.jupiter.api.extension.RegisterExtension;
3535

3636
import static org.hibernate.id.enhanced.SequenceGeneratorLogger.SEQUENCE_GENERATOR_LOGGER;
3737
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -45,8 +45,9 @@
4545
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsSequences.class)
4646
public class SequenceMismatchStrategyFixWithSequenceGeneratorTest extends EntityManagerFactoryBasedFunctionalTest {
4747

48-
@Rule
49-
public LoggerInspectionRule logInspection = new LoggerInspectionRule( SEQUENCE_GENERATOR_LOGGER );
48+
@RegisterExtension
49+
public LoggerInspectionExtension logInspection =
50+
LoggerInspectionExtension.builder().setLogger( SEQUENCE_GENERATOR_LOGGER ).build();
5051

5152
private final Triggerable triggerable = logInspection.watchForLogMessages( "HHH090203:" );
5253

hibernate-core/src/test/java/org/hibernate/orm/test/id/hhh12973/SequenceMismatchStrategyLogTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818
import org.hibernate.boot.spi.MetadataImplementor;
1919
import org.hibernate.cfg.AvailableSettings;
2020
import org.hibernate.service.ServiceRegistry;
21+
import org.hibernate.testing.orm.logger.LoggerInspectionExtension;
2122
import org.hibernate.tool.hbm2ddl.SchemaExport;
2223
import org.hibernate.tool.schema.TargetType;
2324

2425
import org.hibernate.testing.orm.junit.JiraKey;
2526
import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest;
26-
import org.hibernate.testing.logger.LoggerInspectionRule;
2727
import org.hibernate.testing.logger.Triggerable;
2828
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
2929
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
3030
import org.hibernate.testing.util.ServiceRegistryUtil;
31-
import org.junit.Rule;
3231
import org.junit.jupiter.api.AfterAll;
3332
import org.junit.jupiter.api.Test;
33+
import org.junit.jupiter.api.extension.RegisterExtension;
3434

3535
import static org.hibernate.id.enhanced.SequenceGeneratorLogger.SEQUENCE_GENERATOR_LOGGER;
3636
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -43,8 +43,9 @@
4343
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsSequences.class)
4444
public class SequenceMismatchStrategyLogTest extends EntityManagerFactoryBasedFunctionalTest {
4545

46-
@Rule
47-
public LoggerInspectionRule logInspection = new LoggerInspectionRule( SEQUENCE_GENERATOR_LOGGER );
46+
@RegisterExtension
47+
public LoggerInspectionExtension logInspection =
48+
LoggerInspectionExtension.builder().setLogger( SEQUENCE_GENERATOR_LOGGER ).build();
4849

4950
private final Triggerable triggerable = logInspection.watchForLogMessages( "HHH090202:" );
5051

hibernate-core/src/test/java/org/hibernate/orm/test/id/hhh12973/SequenceMismatchStrategyWithoutSequenceGeneratorTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
import org.hibernate.boot.spi.MetadataImplementor;
1616
import org.hibernate.cfg.AvailableSettings;
1717
import org.hibernate.service.ServiceRegistry;
18-
import org.hibernate.testing.logger.LoggerInspectionRule;
1918
import org.hibernate.testing.logger.Triggerable;
2019
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
2120
import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest;
2221
import org.hibernate.testing.orm.junit.JiraKey;
2322
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
23+
import org.hibernate.testing.orm.logger.LoggerInspectionExtension;
2424
import org.hibernate.testing.util.ServiceRegistryUtil;
2525
import org.hibernate.tool.hbm2ddl.SchemaExport;
2626
import org.hibernate.tool.schema.TargetType;
27-
import org.junit.Rule;
2827
import org.junit.jupiter.api.AfterAll;
2928
import org.junit.jupiter.api.Test;
29+
import org.junit.jupiter.api.extension.RegisterExtension;
3030

3131
import java.util.EnumSet;
3232
import java.util.Map;
@@ -43,8 +43,9 @@
4343
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsSequences.class)
4444
public class SequenceMismatchStrategyWithoutSequenceGeneratorTest extends EntityManagerFactoryBasedFunctionalTest {
4545

46-
@Rule
47-
public LoggerInspectionRule logInspection = new LoggerInspectionRule( SEQUENCE_GENERATOR_LOGGER );
46+
@RegisterExtension
47+
public LoggerInspectionExtension logInspection =
48+
LoggerInspectionExtension.builder().setLogger( SEQUENCE_GENERATOR_LOGGER ).build();
4849

4950
private Triggerable triggerable = logInspection.watchForLogMessages( "HHH090203:" );
5051

hibernate-core/src/test/java/org/hibernate/orm/test/id/sequence/NegativeValueSequenceTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@
2323
import org.hibernate.service.spi.ServiceRegistryImplementor;
2424

2525
import org.hibernate.testing.orm.junit.JiraKey;
26-
import org.hibernate.testing.logger.LoggerInspectionRule;
2726
import org.hibernate.testing.logger.Triggerable;
27+
import org.hibernate.testing.orm.logger.LoggerInspectionExtension;
2828
import org.hibernate.testing.util.ServiceRegistryUtil;
29-
import org.junit.Rule;
3029
import org.junit.jupiter.api.Test;
31-
30+
import org.junit.jupiter.api.extension.RegisterExtension;
3231

3332

3433
import static org.hibernate.id.enhanced.SequenceGeneratorLogger.SEQUENCE_GENERATOR_LOGGER;
@@ -41,9 +40,9 @@
4140
* @author Gail Badner
4241
*/
4342
public class NegativeValueSequenceTest {
44-
45-
@Rule
46-
public LoggerInspectionRule logInspection = new LoggerInspectionRule( SEQUENCE_GENERATOR_LOGGER );
43+
@RegisterExtension
44+
public LoggerInspectionExtension logInspection =
45+
LoggerInspectionExtension.builder().setLogger( SEQUENCE_GENERATOR_LOGGER ).build();
4746

4847
@Test
4948
@JiraKey( value = "HHH-5933")

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/OneToOneMapsIdChangeParentTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111

1212

1313
import org.hibernate.testing.orm.junit.JiraKey;
14-
import org.hibernate.testing.logger.LoggerInspectionRule;
1514
import org.hibernate.testing.logger.Triggerable;
1615
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
1716
import org.hibernate.testing.orm.junit.Jpa;
18-
import org.junit.Rule;
17+
import org.hibernate.testing.orm.logger.LoggerInspectionExtension;
1918
import org.junit.jupiter.api.Test;
20-
19+
import org.junit.jupiter.api.extension.RegisterExtension;
2120

2221

2322
import static org.hibernate.internal.CoreMessageLogger.CORE_LOGGER;
@@ -35,9 +34,9 @@
3534
}
3635
)
3736
public class OneToOneMapsIdChangeParentTest {
38-
39-
@Rule
40-
public LoggerInspectionRule logInspection = new LoggerInspectionRule( CORE_LOGGER );
37+
@RegisterExtension
38+
public LoggerInspectionExtension logInspection =
39+
LoggerInspectionExtension.builder().setLogger( CORE_LOGGER ).build();
4140

4241
private final Triggerable triggerable = logInspection.watchForLogMessages( "HHH000502:" );
4342

hibernate-core/src/test/java/org/hibernate/orm/test/persister/entity/TemporaryTableStrategyTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import jakarta.persistence.Table;
1212
import org.hibernate.dialect.OracleDialect;
1313
import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableStrategy;
14-
import org.hibernate.testing.logger.LoggerInspectionRule;
1514
import org.hibernate.testing.logger.Triggerable;
1615
import org.hibernate.testing.orm.junit.DomainModel;
1716
import org.hibernate.testing.orm.junit.JiraKey;
@@ -20,9 +19,10 @@
2019
import org.hibernate.testing.orm.junit.SessionFactory;
2120
import org.hibernate.testing.orm.junit.SessionFactoryScope;
2221
import org.hibernate.testing.orm.junit.Setting;
22+
import org.hibernate.testing.orm.logger.LoggerInspectionExtension;
2323
import org.jboss.logging.Logger;
24-
import org.junit.Rule;
2524
import org.junit.jupiter.api.Test;
25+
import org.junit.jupiter.api.extension.RegisterExtension;
2626

2727
import java.util.Set;
2828

@@ -41,9 +41,9 @@
4141
@RequiresDialect(OracleDialect.class)
4242
public class TemporaryTableStrategyTest {
4343

44-
@Rule
45-
public LoggerInspectionRule logInspection =
46-
new LoggerInspectionRule( Logger.getLogger( GlobalTemporaryTableStrategy.class ) );
44+
@RegisterExtension
45+
public LoggerInspectionExtension logInspection =
46+
LoggerInspectionExtension.builder().setLogger( Logger.getLogger( GlobalTemporaryTableStrategy.class ) ).build();
4747

4848
private final Triggerable triggerable = logInspection.watchForLogMessages( Set.of(
4949
"Creating global-temp ID table",

0 commit comments

Comments
 (0)