|
|
@ -525,24 +525,32 @@ class FlywayAutoConfigurationTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void userConfigurationDslContextDependency() {
|
|
|
|
void whenFlywayIsAutoConfiguredThenJooqDslContextDependsOnFlywayBeans() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, JooqConfiguration.class)
|
|
|
|
.withUserConfiguration(EmbeddedDataSourceConfiguration.class, CustomFlywayWithJooqConfiguration.class)
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition("dslContext");
|
|
|
|
BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition("dslContext");
|
|
|
|
assertThat(beanDefinition.getDependsOn()).containsExactly("flyway");
|
|
|
|
assertThat(beanDefinition.getDependsOn()).containsExactly("flywayInitializer", "flyway");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void userConfigurationWithFlywayMigrationAndDslContextDependency() {
|
|
|
|
void whenCustomMigrationInitializerIsDefinedThenJooqDslContextDependsOnIt() {
|
|
|
|
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class,
|
|
|
|
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, JooqConfiguration.class,
|
|
|
|
CustomFlywayMigrationInitializerWithJooqConfiguration.class).run((context) -> {
|
|
|
|
CustomFlywayMigrationInitializer.class).run((context) -> {
|
|
|
|
BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition("dslContext");
|
|
|
|
BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition("dslContext");
|
|
|
|
assertThat(beanDefinition.getDependsOn()).containsExactly("flywayMigrationInitializer", "flyway");
|
|
|
|
assertThat(beanDefinition.getDependsOn()).containsExactly("flywayMigrationInitializer", "flyway");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void whenCustomFlywayIsDefinedThenJooqDslContextDependsOnIt() {
|
|
|
|
|
|
|
|
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, JooqConfiguration.class,
|
|
|
|
|
|
|
|
CustomFlyway.class).run((context) -> {
|
|
|
|
|
|
|
|
BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition("dslContext");
|
|
|
|
|
|
|
|
assertThat(beanDefinition.getDependsOn()).containsExactly("customFlyway");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
static class FlywayDataSourceConfiguration {
|
|
|
|
static class FlywayDataSourceConfiguration {
|
|
|
|
|
|
|
|
|
|
|
@ -619,6 +627,16 @@ class FlywayAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
|
|
|
static class CustomFlyway {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
Flyway customFlyway() {
|
|
|
|
|
|
|
|
return Flyway.configure().load();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
static class CustomFlywayMigrationInitializerWithJpaConfiguration {
|
|
|
|
static class CustomFlywayMigrationInitializerWithJpaConfiguration {
|
|
|
|
|
|
|
|
|
|
|
@ -771,34 +789,8 @@ class FlywayAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
static class CustomFlywayWithJooqConfiguration {
|
|
|
|
static class JooqConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
Flyway flyway(DataSource dataSource) {
|
|
|
|
|
|
|
|
return Flyway.configure().dataSource(dataSource).load();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
DSLContext dslContext() {
|
|
|
|
|
|
|
|
return new DefaultDSLContext(SQLDialect.H2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
|
|
|
protected static class CustomFlywayMigrationInitializerWithJooqConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final DataSource dataSource;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected CustomFlywayMigrationInitializerWithJooqConfiguration(DataSource dataSource) {
|
|
|
|
|
|
|
|
this.dataSource = dataSource;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
public FlywayMigrationInitializer flywayMigrationInitializer(Flyway flyway) {
|
|
|
|
|
|
|
|
return new FlywayMigrationInitializer(flyway);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
DSLContext dslContext() {
|
|
|
|
DSLContext dslContext() {
|
|
|
|