|
|
@ -78,6 +78,32 @@ class DataSourcePropertiesTests {
|
|
|
|
assertThat(properties.determineUrl()).isEqualTo("jdbc:mysql://mydb");
|
|
|
|
assertThat(properties.determineUrl()).isEqualTo("jdbc:mysql://mydb");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void determineIsEmbeddedWithExplicitConfigforH2() throws Exception {
|
|
|
|
|
|
|
|
DataSourceProperties properties = new DataSourceProperties();
|
|
|
|
|
|
|
|
properties.setUrl("jdbc:h2:~/test");
|
|
|
|
|
|
|
|
properties.setUsername("");
|
|
|
|
|
|
|
|
properties.setPassword("");
|
|
|
|
|
|
|
|
properties.afterPropertiesSet();
|
|
|
|
|
|
|
|
assertThat(properties.getUrl()).isEqualTo("jdbc:h2:~/test");
|
|
|
|
|
|
|
|
assertThat(properties.determineUrl()).isEqualTo("jdbc:h2:~/test");
|
|
|
|
|
|
|
|
assertThat(properties.determineUsername()).isEqualTo("");
|
|
|
|
|
|
|
|
assertThat(properties.determinePassword()).isEqualTo("");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void determineWithExplicitConfigforH2WithCustomJdbcUrl() throws Exception {
|
|
|
|
|
|
|
|
DataSourceProperties properties = new DataSourceProperties();
|
|
|
|
|
|
|
|
properties.setUrl("jdbc:h2:~/test");
|
|
|
|
|
|
|
|
properties.setUsername("as");
|
|
|
|
|
|
|
|
properties.setPassword("as");
|
|
|
|
|
|
|
|
properties.afterPropertiesSet();
|
|
|
|
|
|
|
|
assertThat(properties.getUrl()).isEqualTo("jdbc:h2:~/test");
|
|
|
|
|
|
|
|
assertThat(properties.determineUrl()).isEqualTo("jdbc:h2:~/test");
|
|
|
|
|
|
|
|
assertThat(properties.determineUsername()).isEqualTo("as");
|
|
|
|
|
|
|
|
assertThat(properties.determinePassword()).isEqualTo("as");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void determineUrlWithGenerateUniqueName() throws Exception {
|
|
|
|
void determineUrlWithGenerateUniqueName() throws Exception {
|
|
|
|
DataSourceProperties properties = new DataSourceProperties();
|
|
|
|
DataSourceProperties properties = new DataSourceProperties();
|
|
|
@ -98,6 +124,24 @@ class DataSourcePropertiesTests {
|
|
|
|
assertThat(properties.determineUsername()).isEqualTo("sa");
|
|
|
|
assertThat(properties.determineUsername()).isEqualTo("sa");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void determineUsernameWhenEmpty() throws Exception {
|
|
|
|
|
|
|
|
DataSourceProperties properties = new DataSourceProperties();
|
|
|
|
|
|
|
|
properties.setUsername("");
|
|
|
|
|
|
|
|
properties.afterPropertiesSet();
|
|
|
|
|
|
|
|
assertThat(properties.getUsername());
|
|
|
|
|
|
|
|
assertThat(properties.determineUsername()).isEqualTo("sa");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void determineUsernameWhenNull() throws Exception {
|
|
|
|
|
|
|
|
DataSourceProperties properties = new DataSourceProperties();
|
|
|
|
|
|
|
|
properties.setUsername(null);
|
|
|
|
|
|
|
|
properties.afterPropertiesSet();
|
|
|
|
|
|
|
|
assertThat(properties.getUsername());
|
|
|
|
|
|
|
|
assertThat(properties.determineUsername()).isEqualTo("sa");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void determineUsernameWithExplicitConfig() throws Exception {
|
|
|
|
void determineUsernameWithExplicitConfig() throws Exception {
|
|
|
|
DataSourceProperties properties = new DataSourceProperties();
|
|
|
|
DataSourceProperties properties = new DataSourceProperties();
|
|
|
@ -112,7 +156,6 @@ class DataSourcePropertiesTests {
|
|
|
|
DataSourceProperties properties = new DataSourceProperties();
|
|
|
|
DataSourceProperties properties = new DataSourceProperties();
|
|
|
|
properties.afterPropertiesSet();
|
|
|
|
properties.afterPropertiesSet();
|
|
|
|
assertThat(properties.getPassword()).isNull();
|
|
|
|
assertThat(properties.getPassword()).isNull();
|
|
|
|
assertThat(properties.determinePassword()).isEqualTo("");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|