55package org .hibernate .orm .test .mapping .lazytoone ;
66
77import org .hibernate .Hibernate ;
8- import org .hibernate .boot .registry .StandardServiceRegistryBuilder ;
9- import org .hibernate .cfg .AvailableSettings ;
108import org .hibernate .proxy .HibernateProxy ;
119import org .hibernate .stat .spi .StatisticsImplementor ;
1210
13- import org .hibernate .testing .junit4 .BaseNonConfigCoreFunctionalTestCase ;
14- import org .junit .Test ;
11+ import org .hibernate .testing .orm .junit .DomainModel ;
12+ import org .hibernate .testing .orm .junit .SessionFactory ;
13+ import org .hibernate .testing .orm .junit .SessionFactoryScope ;
14+ import org .junit .jupiter .api .Test ;
15+ import org .junit .jupiter .api .AfterEach ;
16+ import org .junit .jupiter .api .BeforeEach ;
1517
1618import static org .hamcrest .CoreMatchers .instanceOf ;
1719import static org .hamcrest .CoreMatchers .is ;
2022/**
2123 * @author Steve Ebersole
2224 */
23- public class LazyToOneTest extends BaseNonConfigCoreFunctionalTestCase {
24-
25- @ Override
26- protected Class <?>[] getAnnotatedClasses () {
27- return new Class [] { Airport .class , Flight .class };
28- }
29-
30- @ Override
31- protected void configureStandardServiceRegistryBuilder (StandardServiceRegistryBuilder ssrb ) {
32- ssrb .applySetting ( AvailableSettings .GENERATE_STATISTICS , "true" );
33- }
34-
35- @ Override
36- protected void prepareTest () throws Exception {
37- inTransaction (
38- (session ) -> {
25+ @ DomainModel (annotatedClasses = {Airport .class , Flight .class })
26+ @ SessionFactory (generateStatistics = true )
27+ public class LazyToOneTest {
28+
29+ @ BeforeEach
30+ protected void prepareTest (SessionFactoryScope scope ) throws Exception {
31+ scope .inTransaction (
32+ session -> {
3933 final Airport austin = new Airport ( 1 , "AUS" );
4034 final Airport baltimore = new Airport ( 2 , "BWI" );
4135
@@ -51,18 +45,18 @@ protected void prepareTest() throws Exception {
5145 );
5246 }
5347
54- @ Override
55- protected void cleanupTestData () throws Exception {
56- sessionFactory (). getSchemaManager (). truncate ();
48+ @ AfterEach
49+ protected void cleanupTestData (SessionFactoryScope scope ) throws Exception {
50+ scope . dropData ();
5751 }
5852
5953 @ Test
60- public void testNonEnhanced () {
61- final StatisticsImplementor statistics = sessionFactory ().getStatistics ();
54+ public void testNonEnhanced (SessionFactoryScope scope ) {
55+ final StatisticsImplementor statistics = scope . getSessionFactory ().getStatistics ();
6256 statistics .clear ();
6357
64- inTransaction (
65- ( session ) -> {
58+ scope . inTransaction (
59+ session -> {
6660 final Flight flight1 = session .byId ( Flight .class ).load ( 1 );
6761
6862 assertThat ( statistics .getPrepareStatementCount (), is ( 1L ) );
0 commit comments