@@ -525,24 +525,32 @@ void initSqlsWithFlywayUrl() {
525
525
}
526
526
527
527
@ Test
528
- void userConfigurationDslContextDependency () {
529
- this .contextRunner
530
- .withUserConfiguration (EmbeddedDataSourceConfiguration .class , CustomFlywayWithJooqConfiguration .class )
528
+ void whenFlywayIsAutoConfiguredThenJooqDslContextDependsOnFlywayBeans () {
529
+ this .contextRunner .withUserConfiguration (EmbeddedDataSourceConfiguration .class , JooqConfiguration .class )
531
530
.run ((context ) -> {
532
531
BeanDefinition beanDefinition = context .getBeanFactory ().getBeanDefinition ("dslContext" );
533
- assertThat (beanDefinition .getDependsOn ()).containsExactly ("flyway" );
532
+ assertThat (beanDefinition .getDependsOn ()).containsExactly ("flywayInitializer" , " flyway" );
534
533
});
535
534
}
536
535
537
536
@ Test
538
- void userConfigurationWithFlywayMigrationAndDslContextDependency () {
539
- this .contextRunner .withUserConfiguration (EmbeddedDataSourceConfiguration .class ,
540
- CustomFlywayMigrationInitializerWithJooqConfiguration .class ).run ((context ) -> {
537
+ void whenCustomMigrationInitializerIsDefinedThenJooqDslContextDependsOnIt () {
538
+ this .contextRunner .withUserConfiguration (EmbeddedDataSourceConfiguration .class , JooqConfiguration . class ,
539
+ CustomFlywayMigrationInitializer .class ).run ((context ) -> {
541
540
BeanDefinition beanDefinition = context .getBeanFactory ().getBeanDefinition ("dslContext" );
542
541
assertThat (beanDefinition .getDependsOn ()).containsExactly ("flywayMigrationInitializer" , "flyway" );
543
542
});
544
543
}
545
544
545
+ @ Test
546
+ void whenCustomFlywayIsDefinedThenJooqDslContextDependsOnIt () {
547
+ this .contextRunner .withUserConfiguration (EmbeddedDataSourceConfiguration .class , JooqConfiguration .class ,
548
+ CustomFlyway .class ).run ((context ) -> {
549
+ BeanDefinition beanDefinition = context .getBeanFactory ().getBeanDefinition ("dslContext" );
550
+ assertThat (beanDefinition .getDependsOn ()).containsExactly ("customFlyway" );
551
+ });
552
+ }
553
+
546
554
@ Configuration (proxyBeanMethods = false )
547
555
static class FlywayDataSourceConfiguration {
548
556
@@ -619,6 +627,16 @@ FlywayMigrationInitializer flywayMigrationInitializer(Flyway flyway) {
619
627
620
628
}
621
629
630
+ @ Configuration (proxyBeanMethods = false )
631
+ static class CustomFlyway {
632
+
633
+ @ Bean
634
+ Flyway customFlyway () {
635
+ return Flyway .configure ().load ();
636
+ }
637
+
638
+ }
639
+
622
640
@ Configuration (proxyBeanMethods = false )
623
641
static class CustomFlywayMigrationInitializerWithJpaConfiguration {
624
642
@@ -771,34 +789,8 @@ FlywayConfigurationCustomizer customizerTwo() {
771
789
772
790
}
773
791
774
- @ Configuration
775
- static class CustomFlywayWithJooqConfiguration {
776
-
777
- @ Bean
778
- Flyway flyway (DataSource dataSource ) {
779
- return Flyway .configure ().dataSource (dataSource ).load ();
780
- }
781
-
782
- @ Bean
783
- DSLContext dslContext () {
784
- return new DefaultDSLContext (SQLDialect .H2 );
785
- }
786
-
787
- }
788
-
789
- @ Configuration
790
- protected static class CustomFlywayMigrationInitializerWithJooqConfiguration {
791
-
792
- private final DataSource dataSource ;
793
-
794
- protected CustomFlywayMigrationInitializerWithJooqConfiguration (DataSource dataSource ) {
795
- this .dataSource = dataSource ;
796
- }
797
-
798
- @ Bean
799
- public FlywayMigrationInitializer flywayMigrationInitializer (Flyway flyway ) {
800
- return new FlywayMigrationInitializer (flyway );
801
- }
792
+ @ Configuration (proxyBeanMethods = false )
793
+ static class JooqConfiguration {
802
794
803
795
@ Bean
804
796
DSLContext dslContext () {
0 commit comments