Skip to content

Commit 830c8fd

Browse files
committed
HHH-19846 Drop JUnit 4 usage
1 parent e53674b commit 830c8fd

File tree

2 files changed

+45
-32
lines changed

2 files changed

+45
-32
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/strategy/Storm.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.annotations.strategy;
6+
67
import jakarta.persistence.Column;
78
import jakarta.persistence.Embedded;
89
import jakarta.persistence.Entity;

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/strategy/StrategyTest.java

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,57 @@
44
*/
55
package org.hibernate.orm.test.annotations.strategy;
66

7-
import org.hibernate.Session;
8-
import org.hibernate.Transaction;
9-
import org.hibernate.boot.MetadataBuilder;
7+
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
108
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
11-
12-
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
13-
import org.junit.Test;
9+
import org.hibernate.cfg.AvailableSettings;
10+
import org.hibernate.testing.orm.junit.DomainModel;
11+
import org.hibernate.testing.orm.junit.ServiceRegistry;
12+
import org.hibernate.testing.orm.junit.SessionFactory;
13+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
14+
import org.hibernate.testing.orm.junit.SettingProvider;
15+
import org.junit.jupiter.api.Test;
1416

1517
/**
1618
* @author Emmanuel Bernard
1719
*/
18-
public class StrategyTest extends BaseNonConfigCoreFunctionalTestCase {
19-
@Test
20-
public void testComponentSafeStrategy() throws Exception {
21-
Session s = openSession();
22-
Transaction tx = s.beginTransaction();
23-
Location start = new Location();
24-
start.setCity( "Paris" );
25-
start.setCountry( "France" );
26-
Location end = new Location();
27-
end.setCity( "London" );
28-
end.setCountry( "UK" );
29-
Storm storm = new Storm();
30-
storm.setEnd( end );
31-
storm.setStart( start );
32-
s.persist( storm );
33-
s.flush();
34-
tx.rollback();
35-
s.close();
36-
}
20+
@DomainModel(
21+
annotatedClasses = {
22+
Storm.class
23+
}
24+
)
25+
@SessionFactory
26+
@ServiceRegistry(
27+
settingProviders = @SettingProvider(
28+
settingName = AvailableSettings.IMPLICIT_NAMING_STRATEGY,
29+
provider = StrategyTest.ImplicitNamyStrategyProvider.class
30+
)
31+
)
32+
public class StrategyTest {
3733

38-
@Override
39-
protected void configureMetadataBuilder(MetadataBuilder metadataBuilder) {
40-
super.configureMetadataBuilder( metadataBuilder );
41-
metadataBuilder.applyImplicitNamingStrategy( ImplicitNamingStrategyComponentPathImpl.INSTANCE );
34+
public static class ImplicitNamyStrategyProvider implements SettingProvider.Provider<ImplicitNamingStrategy> {
35+
@Override
36+
public ImplicitNamingStrategy getSetting() {
37+
return ImplicitNamingStrategyComponentPathImpl.INSTANCE;
38+
}
4239
}
4340

44-
@Override
45-
protected Class[] getAnnotatedClasses() {
46-
return new Class[] { Storm.class };
41+
42+
@Test
43+
public void testComponentSafeStrategy(SessionFactoryScope scope) {
44+
scope.inTransaction(
45+
session -> {
46+
Location start = new Location();
47+
start.setCity( "Paris" );
48+
start.setCountry( "France" );
49+
Location end = new Location();
50+
end.setCity( "London" );
51+
end.setCountry( "UK" );
52+
Storm storm = new Storm();
53+
storm.setEnd( end );
54+
storm.setStart( start );
55+
session.persist( storm );
56+
session.flush();
57+
}
58+
);
4759
}
4860
}

0 commit comments

Comments
 (0)