|
36 | 36 | import org.junit.jupiter.api.Test; |
37 | 37 | import org.mockito.InOrder; |
38 | 38 |
|
39 | | -import org.mockito.internal.util.MockUtil; |
40 | 39 | import org.springframework.beans.factory.BeanCreationException; |
41 | 40 | import org.springframework.boot.autoconfigure.AutoConfigurations; |
42 | 41 | import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; |
|
56 | 55 | import org.springframework.stereotype.Component; |
57 | 56 |
|
58 | 57 | import static org.assertj.core.api.Assertions.assertThat; |
59 | | -import static org.junit.jupiter.api.Assertions.assertTrue; |
60 | 58 | import static org.mockito.ArgumentMatchers.any; |
61 | 59 | import static org.mockito.BDDMockito.given; |
62 | 60 | import static org.mockito.Mockito.inOrder; |
@@ -478,10 +476,11 @@ public void undoSqlMigrationPrefix() { |
478 | 476 | public void customFlywayClassLoader() { |
479 | 477 | this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class, |
480 | 478 | ResourceLoaderConfiguration.class).run((context) -> { |
481 | | - assertThat(context).hasSingleBean(Flyway.class); |
482 | | - Flyway flyway = context.getBean(Flyway.class); |
483 | | - assertTrue(MockUtil.isMock(flyway.getConfiguration().getClassLoader())); |
484 | | - }); |
| 479 | + assertThat(context).hasSingleBean(Flyway.class); |
| 480 | + Flyway flyway = context.getBean(Flyway.class); |
| 481 | + assertThat(flyway.getConfiguration().getClassLoader()) |
| 482 | + .isInstanceOf(CustomClassLoader.class); |
| 483 | + }); |
485 | 484 | } |
486 | 485 |
|
487 | 486 | @Configuration(proxyBeanMethods = false) |
@@ -509,7 +508,8 @@ protected static class ResourceLoaderConfiguration { |
509 | 508 | @Bean |
510 | 509 | @Primary |
511 | 510 | public ResourceLoader customClassLoader() { |
512 | | - return new DefaultResourceLoader(mock(ClassLoader.class)); |
| 511 | + return new DefaultResourceLoader( |
| 512 | + new CustomClassLoader(getClass().getClassLoader())); |
513 | 513 | } |
514 | 514 |
|
515 | 515 | } |
@@ -629,4 +629,12 @@ public FlywayConfigurationCustomizer customizerTwo() { |
629 | 629 |
|
630 | 630 | } |
631 | 631 |
|
| 632 | + private static final class CustomClassLoader extends ClassLoader { |
| 633 | + |
| 634 | + private CustomClassLoader(ClassLoader parent) { |
| 635 | + super(parent); |
| 636 | + } |
| 637 | + |
| 638 | + } |
| 639 | + |
632 | 640 | } |
0 commit comments