Polish
This commit is contained in:
@@ -33,6 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for {@link BasicDataSourceExample}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
|
||||
@@ -47,12 +47,10 @@ public class CompleteTwoDataSourcesExampleTests {
|
||||
@Test
|
||||
public void validateConfiguration() throws SQLException {
|
||||
assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(2);
|
||||
|
||||
DataSource dataSource = this.context.getBean(DataSource.class);
|
||||
assertThat(this.context.getBean("fooDataSource")).isSameAs(dataSource);
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL())
|
||||
.startsWith("jdbc:h2:mem:");
|
||||
|
||||
DataSource barDataSource = this.context.getBean("barDataSource",
|
||||
DataSource.class);
|
||||
assertThat(barDataSource.getConnection().getMetaData().getURL())
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* A sample {@link SpringBootConfiguration} that only enables the auto-configuration
|
||||
* for the {@link DataSource}.
|
||||
* A sample {@link SpringBootConfiguration} that only enables the auto-configuration for
|
||||
* the {@link DataSource}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
||||
@@ -38,8 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = {
|
||||
"app.datasource.bar.url=jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1",
|
||||
@SpringBootTest(properties = { "app.datasource.bar.url=jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1",
|
||||
"app.datasource.bar.max-total=42" })
|
||||
@Import(SimpleTwoDataSourcesExample.SimpleDataSourcesConfiguration.class)
|
||||
public class SimpleTwoDataSourcesExampleTests {
|
||||
@@ -50,16 +49,13 @@ public class SimpleTwoDataSourcesExampleTests {
|
||||
@Test
|
||||
public void validateConfiguration() throws SQLException {
|
||||
assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(2);
|
||||
|
||||
DataSource dataSource = this.context.getBean(DataSource.class);
|
||||
assertThat(this.context.getBean("fooDataSource")).isSameAs(dataSource);
|
||||
assertThat(dataSource.getConnection().getMetaData().getURL())
|
||||
.startsWith("jdbc:h2:mem:");
|
||||
|
||||
BasicDataSource barDataSource = this.context.getBean("barDataSource",
|
||||
BasicDataSource.class);
|
||||
assertThat(barDataSource.getUrl())
|
||||
.isEqualTo("jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1");
|
||||
assertThat(barDataSource.getUrl()).isEqualTo("jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1");
|
||||
assertThat(barDataSource.getMaxTotal()).isEqualTo(42);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user