mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-10 11:29:20 +00:00
Merge branch '3.4.x'
Closes gh-45992
This commit is contained in:
+5
-1
@@ -508,6 +508,9 @@ public final class DataSourceBuilder<T extends DataSource> {
|
||||
}
|
||||
|
||||
private String convertToString(V value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (String.class.equals(this.type)) {
|
||||
return (String) value;
|
||||
}
|
||||
@@ -712,7 +715,8 @@ public final class DataSourceBuilder<T extends DataSource> {
|
||||
@SuppressWarnings("unchecked")
|
||||
SimpleDataSourceProperties() {
|
||||
add(DataSourceProperty.URL, SimpleDriverDataSource::getUrl, SimpleDriverDataSource::setUrl);
|
||||
add(DataSourceProperty.DRIVER_CLASS_NAME, Class.class, (dataSource) -> dataSource.getDriver().getClass(),
|
||||
add(DataSourceProperty.DRIVER_CLASS_NAME, Class.class,
|
||||
(dataSource) -> (dataSource.getDriver() != null) ? dataSource.getDriver().getClass() : null,
|
||||
SimpleDriverDataSource::setDriverClass);
|
||||
add(DataSourceProperty.USERNAME, SimpleDriverDataSource::getUsername, SimpleDriverDataSource::setUsername);
|
||||
add(DataSourceProperty.PASSWORD, SimpleDriverDataSource::getPassword, SimpleDriverDataSource::setPassword);
|
||||
|
||||
+10
@@ -358,6 +358,16 @@ class DataSourceBuilderTests {
|
||||
.isThrownBy(() -> DataSourceBuilder.derivedFrom(dataSource).url("example.org").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildWhenDerivedFromSimpleDriverDataSourceAndDriverNotSetBuilds() {
|
||||
SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
|
||||
dataSource.setUsername("test");
|
||||
dataSource.setPassword("secret");
|
||||
dataSource.setUrl("jdbc:postgresql://localhost:5432/postgres");
|
||||
assertThatNoException()
|
||||
.isThrownBy(() -> DataSourceBuilder.derivedFrom(dataSource).type(SimpleDriverDataSource.class).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
void buildWhenDerivedFromOracleDataSourceWithPasswordSetReturnsDataSource() throws Exception {
|
||||
oracle.jdbc.datasource.impl.OracleDataSource dataSource = new oracle.jdbc.datasource.impl.OracleDataSource();
|
||||
|
||||
Reference in New Issue
Block a user