Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ private V convertFromString(String value) {
}

private String convertToString(V value) {
if (value == null) {
return null;
}
if (String.class.equals(this.type)) {
return (String) value;
}
Expand Down Expand Up @@ -712,7 +715,8 @@ private static class SimpleDataSourceProperties extends MappedDataSourceProperti
@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 ? null : dataSource.getDriver().getClass(),
SimpleDriverDataSource::setDriverClass);
add(DataSourceProperty.USERNAME, SimpleDriverDataSource::getUsername, SimpleDriverDataSource::setUsername);
add(DataSourceProperty.PASSWORD, SimpleDriverDataSource::getPassword, SimpleDriverDataSource::setPassword);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,16 @@ void buildWhenDerivedFromOracleUcpWithPasswordNotSetThrowsException() throws Exc
.isThrownBy(() -> DataSourceBuilder.derivedFrom(dataSource).url("example.org").build());
}

@Test
void buildWhenDerivedFromSimpleDriverDataSourceWithDriverNotSetSucceeds() throws Exception {
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();
Expand Down