|
|
|
|
@ -23,6 +23,8 @@ import java.util.LinkedHashMap;
@@ -23,6 +23,8 @@ import java.util.LinkedHashMap;
|
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Properties; |
|
|
|
|
|
|
|
|
|
import liquibase.integration.spring.SpringLiquibase; |
|
|
|
|
import org.flywaydb.core.Flyway; |
|
|
|
|
import org.junit.After; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
@ -61,6 +63,7 @@ import org.springframework.core.io.support.PropertiesLoaderUtils;
@@ -61,6 +63,7 @@ import org.springframework.core.io.support.PropertiesLoaderUtils;
|
|
|
|
|
import org.springframework.validation.BindException; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
import static org.mockito.Mockito.mock; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Tests for {@link EndpointAutoConfiguration}. |
|
|
|
|
@ -206,6 +209,15 @@ public class EndpointAutoConfigurationTests {
@@ -206,6 +209,15 @@ public class EndpointAutoConfigurationTests {
|
|
|
|
|
assertThat(endpoint.invoke()).hasSize(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void flywayEndpointIsDisabledWhenThereAreMultipleFlywayBeans() { |
|
|
|
|
this.context = new AnnotationConfigApplicationContext(); |
|
|
|
|
this.context.register(MultipleFlywayBeansConfig.class, |
|
|
|
|
EndpointAutoConfiguration.class); |
|
|
|
|
this.context.refresh(); |
|
|
|
|
assertThat(this.context.getBeansOfType(FlywayEndpoint.class)).hasSize(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testLiquibaseEndpoint() { |
|
|
|
|
this.context = new AnnotationConfigApplicationContext(); |
|
|
|
|
@ -217,6 +229,15 @@ public class EndpointAutoConfigurationTests {
@@ -217,6 +229,15 @@ public class EndpointAutoConfigurationTests {
|
|
|
|
|
assertThat(endpoint.invoke()).hasSize(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void liquibaseEndpointIsDisabledWhenThereAreMultipleSpringLiquibaseBeans() { |
|
|
|
|
this.context = new AnnotationConfigApplicationContext(); |
|
|
|
|
this.context.register(MultipleLiquibaseBeansConfig.class, |
|
|
|
|
EndpointAutoConfiguration.class); |
|
|
|
|
this.context.refresh(); |
|
|
|
|
assertThat(this.context.getBeansOfType(LiquibaseEndpoint.class)).hasSize(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void load(Class<?>... config) { |
|
|
|
|
this.context = new AnnotationConfigApplicationContext(); |
|
|
|
|
this.context.register(config); |
|
|
|
|
@ -287,4 +308,34 @@ public class EndpointAutoConfigurationTests {
@@ -287,4 +308,34 @@ public class EndpointAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
|
static class MultipleFlywayBeansConfig { |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
Flyway flywayOne() { |
|
|
|
|
return mock(Flyway.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
Flyway flywayTwo() { |
|
|
|
|
return mock(Flyway.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
|
static class MultipleLiquibaseBeansConfig { |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
SpringLiquibase liquibaseOne() { |
|
|
|
|
return mock(SpringLiquibase.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
SpringLiquibase liquibaseTwo() { |
|
|
|
|
return mock(SpringLiquibase.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|