@Test public void determineUrlWithGenerateUniqueName() throws Exception { DataSourceProperties properties = new DataSourceProperties(); properties.setGenerateUniqueName(true); properties.afterPropertiesSet(); assertThat(properties.determineUrl()).isEqualTo(properties.determineUrl()); DataSourceProperties properties2 = new DataSourceProperties(); properties2.setGenerateUniqueName(true); properties2.afterPropertiesSet(); assertThat(properties.determineUrl()).isNotEqualTo(properties2.determineUrl()); }
@Test public void determinePassword() throws Exception { DataSourceProperties properties = new DataSourceProperties(); properties.afterPropertiesSet(); assertThat(properties.getPassword()).isNull(); assertThat(properties.determinePassword()).isEqualTo(""); }
@Test public void determineUrl() throws Exception { DataSourceProperties properties = new DataSourceProperties(); properties.afterPropertiesSet(); assertThat(properties.getUrl()).isNull(); assertThat(properties.determineUrl()).isEqualTo(EmbeddedDatabaseConnection.H2.getUrl()); }
@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 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 public void determinePasswordWithExplicitConfig() throws Exception { DataSourceProperties properties = new DataSourceProperties(); properties.setPassword("bar"); properties.afterPropertiesSet(); assertThat(properties.getPassword()).isEqualTo("bar"); assertThat(properties.determinePassword()).isEqualTo("bar"); }