@ -1,5 +1,5 @@
/ *
* Copyright 2012 - 202 0 the original author or authors .
* Copyright 2012 - 202 2 the original author or authors .
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.flyway ;
import java.util.UUID ;
import org.flywaydb.core.Flyway ;
import org.flywaydb.core.api.Location ;
import org.flywaydb.core.api.callback.Callback ;
@ -25,7 +27,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.InOrder ;
import org.springframework.boot.autoconfigure.AutoConfigurations ;
import org.springframework.boot.autoconfigure.jdbc. Embedded DataSourceConfiguration;
import org.springframework.boot.autoconfigure.jdbc. DataSourceAuto Configuration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner ;
import org.springframework.boot.testsupport.classpath.ClassPathOverrides ;
import org.springframework.context.annotation.Bean ;
@ -48,11 +50,11 @@ class Flyway6xAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner ( )
. withConfiguration ( AutoConfigurations . of ( FlywayAutoConfiguration . class ) )
. withPropertyValues ( "spring.datasource. generate-unique-name=true" ) ;
. withPropertyValues ( "spring.datasource. url:jdbc:hsqldb:mem:" + UUID . randomUUID ( ) ) ;
@Test
void defaultFlyway ( ) {
this . contextRunner . withUserConfiguration ( Embedded DataSourceConfiguration. class ) . run ( ( context ) - > {
this . contextRunner . withUserConfiguration ( DataSourceAuto Configuration. class ) . run ( ( context ) - > {
assertThat ( context ) . hasSingleBean ( Flyway . class ) ;
Flyway flyway = context . getBean ( Flyway . class ) ;
assertThat ( flyway . getConfiguration ( ) . getLocations ( ) )
@ -62,7 +64,7 @@ class Flyway6xAutoConfigurationTests {
@Test
void callbacksAreConfiguredAndOrdered ( ) {
this . contextRunner . withUserConfiguration ( Embedded DataSourceConfiguration. class , CallbackConfiguration . class )
this . contextRunner . withUserConfiguration ( DataSourceAuto Configuration. class , CallbackConfiguration . class )
. run ( ( context ) - > {
assertThat ( context ) . hasSingleBean ( Flyway . class ) ;
Flyway flyway = context . getBean ( Flyway . class ) ;