Restore DataSourceProperties get...() methods
Restore original get method functionality in DataSourceProperties in a deprecated form. Fixes gh-6406
This commit is contained in:
parent
48596dfbde
commit
037e697406
|
@ -181,12 +181,14 @@ public class DataSourceProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the configured driver or {@code null} if none was configured.
|
||||
* @return the configured driver
|
||||
* Determine the driver to use based on this configuration and the environment.
|
||||
* @return the driver to use
|
||||
* @see #determineDriverClassName()
|
||||
* @deprecated as for 1.4 in favor of {@link #determineDriverClassName()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getDriverClassName() {
|
||||
return this.driverClassName;
|
||||
return determineDriverClassName();
|
||||
}
|
||||
|
||||
public void setDriverClassName(String driverClassName) {
|
||||
|
@ -236,12 +238,14 @@ public class DataSourceProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the configured url or {@code null} if none was configured.
|
||||
* @return the configured url
|
||||
* Determine the url to use based on this configuration and the environment.
|
||||
* @return the url to use
|
||||
* @see #determineUrl()
|
||||
* @deprecated as of 1.4 in favor of {@link #determineUrl()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
return determineUrl();
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
|
@ -266,12 +270,14 @@ public class DataSourceProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the configured username or {@code null} if none was configured.
|
||||
* @return the configured username
|
||||
* Determine the username to use based on this configuration and the environment.
|
||||
* @return the username to use
|
||||
* @see #determineUsername()
|
||||
* @deprecated as of 1.4 in favor of {@link #determineUsername()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
return determineUsername();
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
|
@ -294,12 +300,14 @@ public class DataSourceProperties
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the configured password or {@code null} if none was configured.
|
||||
* @return the configured password
|
||||
* Determine the password to use based on this configuration and the environment.
|
||||
* @return the password to use
|
||||
* @see #determinePassword()
|
||||
* @deprecated as of 1.4 in favor of {@link #determinePassword()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
return determinePassword();
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
|
|
|
@ -29,74 +29,134 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
public class DataSourcePropertiesTests {
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void getDriver() {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.setUrl("jdbc:mysql://mydb");
|
||||
assertThat(properties.getDriverClassName()).isEqualTo("com.mysql.jdbc.Driver");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineDriver() {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.setUrl("jdbc:mysql://mydb");
|
||||
assertThat(properties.getDriverClassName()).isNull();
|
||||
assertThat(properties.determineDriverClassName())
|
||||
.isEqualTo("com.mysql.jdbc.Driver");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void getDriverWithExplicitConfig() {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.setUrl("jdbc:mysql://mydb");
|
||||
properties.setDriverClassName("org.hsqldb.jdbcDriver");
|
||||
assertThat(properties.getDriverClassName()).isEqualTo("org.hsqldb.jdbcDriver");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineDriverWithExplicitConfig() {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.setUrl("jdbc:mysql://mydb");
|
||||
properties.setDriverClassName("org.hsqldb.jdbcDriver");
|
||||
assertThat(properties.getDriverClassName()).isEqualTo("org.hsqldb.jdbcDriver");
|
||||
assertThat(properties.determineDriverClassName())
|
||||
.isEqualTo("org.hsqldb.jdbcDriver");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void getUrl() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getUrl()).isEqualTo(EmbeddedDatabaseConnection.H2.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineUrl() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getUrl()).isNull();
|
||||
assertThat(properties.determineUrl())
|
||||
.isEqualTo(EmbeddedDatabaseConnection.H2.getUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void getUrlWithExplicitConfig() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.setUrl("jdbc:mysql://mydb");
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getUrl()).isEqualTo("jdbc:mysql://mydb");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineUrlWithExplicitConfig() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.setUrl("jdbc:mysql://mydb");
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getUrl()).isEqualTo("jdbc:mysql://mydb");
|
||||
assertThat(properties.determineUrl()).isEqualTo("jdbc:mysql://mydb");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void getUsername() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getUsername()).isEqualTo("sa");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineUsername() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getUsername()).isNull();
|
||||
assertThat(properties.determineUsername()).isEqualTo("sa");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void getUsernameWithExplicitConfig() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.setUsername("foo");
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getUsername()).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determineUsernameWithExplicitConfig() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.setUsername("foo");
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getUsername()).isEqualTo("foo");
|
||||
assertThat(properties.determineUsername()).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void getPassword() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getPassword()).isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determinePassword() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getPassword()).isNull();
|
||||
assertThat(properties.determinePassword()).isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void getPasswordWithExplicitConfig() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.setPassword("bar");
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getPassword()).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void determinePasswordWithExplicitConfig() throws Exception {
|
||||
DataSourceProperties properties = new DataSourceProperties();
|
||||
properties.setPassword("bar");
|
||||
properties.afterPropertiesSet();
|
||||
assertThat(properties.getPassword()).isEqualTo("bar");
|
||||
assertThat(properties.determinePassword()).isEqualTo("bar");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue