30
30
import org .flywaydb .core .api .callback .Context ;
31
31
import org .flywaydb .core .api .callback .Event ;
32
32
import org .flywaydb .core .api .callback .FlywayCallback ;
33
- import org .flywaydb .core .internal .jdbc .DriverDataSource ;
34
33
import org .hibernate .engine .transaction .jta .platform .internal .NoJtaPlatform ;
35
34
import org .junit .Test ;
36
35
import org .mockito .InOrder ;
@@ -105,11 +104,10 @@ public void createDataSourceFallbackToEmbeddedProperties() {
105
104
this .contextRunner .withUserConfiguration (EmbeddedDataSourceConfiguration .class )
106
105
.withPropertyValues ("spring.flyway.url:jdbc:hsqldb:mem:flywaytest" ).run ((context ) -> {
107
106
assertThat (context ).hasSingleBean (Flyway .class );
108
- assertThat (context .getBean (Flyway .class ).getDataSource ()).isNotNull ();
109
- assertThat (((DriverDataSource ) context .getBean (Flyway .class ).getDataSource ()).getUser ())
110
- .isEqualTo ("sa" );
111
- assertThat (((DriverDataSource ) context .getBean (Flyway .class ).getDataSource ()).getPassword ())
112
- .isEqualTo ("" );
107
+ DataSource dataSource = context .getBean (Flyway .class ).getDataSource ();
108
+ assertThat (dataSource ).isNotNull ();
109
+ assertThat (dataSource ).hasFieldOrPropertyWithValue ("user" , "sa" );
110
+ assertThat (dataSource ).hasFieldOrPropertyWithValue ("password" , "" );
113
111
});
114
112
}
115
113
@@ -118,9 +116,9 @@ public void createDataSourceWithUserAndFallbackToEmbeddedProperties() {
118
116
this .contextRunner .withUserConfiguration (EmbeddedDataSourceConfiguration .class )
119
117
.withPropertyValues ("spring.flyway.user:sa" ).run ((context ) -> {
120
118
assertThat (context ).hasSingleBean (Flyway .class );
121
- assertThat ( context .getBean (Flyway .class ).getDataSource ()). isNotNull ();
122
- assertThat ((( DriverDataSource ) context . getBean ( Flyway . class ). getDataSource ()). getUrl ())
123
- .startsWith ("jdbc:h2:mem:" );
119
+ DataSource dataSource = context .getBean (Flyway .class ).getDataSource ();
120
+ assertThat (dataSource ). isNotNull ();
121
+ assertThat ( dataSource ). extracting ( "url" ). hasSize ( 1 ). first (). asString () .startsWith ("jdbc:h2:mem:" );
124
122
});
125
123
}
126
124
0 commit comments