@ -73,6 +73,14 @@ class DataSourceBuilderTests {
assertThat ( hikariDataSource . getJdbcUrl ( ) ) . isEqualTo ( "jdbc:h2:test" ) ;
}
@Test // gh-26633
void buildWhenHikariDataSourceWithNullPasswordReturnsHikariDataSource ( ) {
this . dataSource = DataSourceBuilder . create ( ) . url ( "jdbc:h2:test" ) . username ( "test" ) . password ( null ) . build ( ) ;
assertThat ( this . dataSource ) . isInstanceOf ( HikariDataSource . class ) ;
HikariDataSource hikariDataSource = ( HikariDataSource ) this . dataSource ;
assertThat ( hikariDataSource . getJdbcUrl ( ) ) . isEqualTo ( "jdbc:h2:test" ) ;
}
@Test
void buildWhenHikariNotAvailableReturnsTomcatDataSource ( ) {
this . dataSource = DataSourceBuilder . create ( new HidePackagesClassLoader ( "com.zaxxer.hikari" ) ) . url ( "jdbc:h2:test" )
@ -80,6 +88,13 @@ class DataSourceBuilderTests {
assertThat ( this . dataSource ) . isInstanceOf ( org . apache . tomcat . jdbc . pool . DataSource . class ) ;
}
@Test // gh-26633
void buildWhenTomcatDataSourceWithNullPasswordReturnsDataSource ( ) {
this . dataSource = DataSourceBuilder . create ( new HidePackagesClassLoader ( "com.zaxxer.hikari" ) ) . url ( "jdbc:h2:test" )
. username ( "test" ) . password ( null ) . build ( ) ;
assertThat ( this . dataSource ) . isInstanceOf ( org . apache . tomcat . jdbc . pool . DataSource . class ) ;
}
@Test
void buildWhenHikariAndTomcatNotAvailableReturnsDbcp2DataSource ( ) {
this . dataSource = DataSourceBuilder
@ -88,6 +103,14 @@ class DataSourceBuilderTests {
assertThat ( this . dataSource ) . isInstanceOf ( BasicDataSource . class ) ;
}
@Test // gh-26633
void buildWhenDbcp2DataSourceWithNullPasswordReturnsDbcp2DataSource ( ) {
this . dataSource = DataSourceBuilder
. create ( new HidePackagesClassLoader ( "com.zaxxer.hikari" , "org.apache.tomcat.jdbc.pool" ) )
. url ( "jdbc:h2:test" ) . username ( "test" ) . password ( null ) . build ( ) ;
assertThat ( this . dataSource ) . isInstanceOf ( BasicDataSource . class ) ;
}
@Test
void buildWhenHikariAndTomcatAndDbcpNotAvailableReturnsOracleUcpDataSource ( ) {
this . dataSource = DataSourceBuilder . create ( new HidePackagesClassLoader ( "com.zaxxer.hikari" ,