1111
1212import org .hibernate .annotations .GenericGenerator ;
1313import org .hibernate .cfg .AvailableSettings ;
14- import org .hibernate .cfg .Configuration ;
1514import org .hibernate .cfg .Environment ;
1615import org .hibernate .dialect .H2Dialect ;
17- import org .hibernate .id .SequenceMismatchStrategy ;
16+ import org .hibernate .testing .orm .junit .DomainModel ;
17+ import org .hibernate .testing .orm .junit .ServiceRegistry ;
18+ import org .hibernate .testing .orm .junit .SessionFactory ;
19+ import org .hibernate .testing .orm .junit .Setting ;
20+ import org .hibernate .testing .orm .junit .SettingProvider ;
1821import org .hibernate .tool .schema .extract .spi .SequenceInformationExtractor ;
1922
20- import org .hibernate .testing .RequiresDialect ;
23+ import org .hibernate .testing .orm . junit . RequiresDialect ;
2124import org .hibernate .testing .orm .junit .JiraKey ;
22- import org .hibernate .testing .junit4 .BaseCoreFunctionalTestCase ;
23- import org .junit .Test ;
25+ import org .junit .jupiter .api .Test ;
2426
2527/**
2628 * Verifies that setting {@code AvailableSettings.SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY} to {@code none}
2729 * is going to skip loading the sequence information from the database.
2830 */
2931@ RequiresDialect ( H2Dialect .class )
3032@ JiraKey ( value = "HHH-14667" )
31- public class SkipLoadingSequenceInformationTest extends BaseCoreFunctionalTestCase {
32-
33- @ Override
34- protected void configure ( Configuration configuration ) {
35- configuration . setProperty ( AvailableSettings . SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY , SequenceMismatchStrategy . NONE );
36- configuration . setProperty ( Environment . DIALECT , VetoingDialect . class );
37- }
33+ @ DomainModel ( annotatedClasses = { SkipLoadingSequenceInformationTest . SequencingEntity . class })
34+ @ SessionFactory
35+ @ ServiceRegistry (
36+ settings = { @ Setting ( name = AvailableSettings . SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY , value = "NONE" ) },
37+ settingProviders = { @ SettingProvider ( settingName = Environment . DIALECT , provider = SkipLoadingSequenceInformationTest . VetoingDialectClassProvider . class ) }
38+ )
39+ public class SkipLoadingSequenceInformationTest {
3840
3941 @ Entity (name ="seqentity" )
4042 static class SequencingEntity {
@@ -51,11 +53,6 @@ static class SequencingEntity {
5153 String name ;
5254 }
5355
54- @ Override
55- protected Class <?>[] getAnnotatedClasses () {
56- return new Class []{SequencingEntity .class };
57- }
58-
5956 @ Test
6057 public void test () {
6158 // If it's able to boot, we're good.
@@ -68,4 +65,11 @@ public SequenceInformationExtractor getSequenceInformationExtractor() {
6865 }
6966 }
7067
68+ public static class VetoingDialectClassProvider implements SettingProvider .Provider <Class <?>> {
69+ @ Override
70+ public Class <?> getSetting () {
71+ return VetoingDialect .class ;
72+ }
73+ }
74+
7175}
0 commit comments