use of cn.taketoday.jdbc.datasource.AbstractDriverBasedDataSource in project today-infrastructure by TAKETODAY.
the class JdbcNamespaceIntegrationTests method assertCorrectSetupAndCloseContext.
private void assertCorrectSetupAndCloseContext(String file, int count, String... dataSources) {
try (ConfigurableApplicationContext context = context(file)) {
for (String dataSourceName : dataSources) {
DataSource dataSource = context.getBean(dataSourceName, DataSource.class);
assertNumRowsInTestTable(new JdbcTemplate(dataSource), count);
assertThat(dataSource instanceof AbstractDriverBasedDataSource).isTrue();
AbstractDriverBasedDataSource adbDataSource = (AbstractDriverBasedDataSource) dataSource;
assertThat(adbDataSource.getUrl()).contains(dataSourceName);
}
}
}
use of cn.taketoday.jdbc.datasource.AbstractDriverBasedDataSource in project today-infrastructure by TAKETODAY.
the class JdbcNamespaceIntegrationTests method assertCorrectSetupForSingleDataSource.
private void assertCorrectSetupForSingleDataSource(String file, Predicate<String> urlPredicate) {
try (ConfigurableApplicationContext context = context(file)) {
DataSource dataSource = context.getBean(DataSource.class);
assertNumRowsInTestTable(new JdbcTemplate(dataSource), 1);
assertThat(dataSource instanceof AbstractDriverBasedDataSource).isTrue();
AbstractDriverBasedDataSource adbDataSource = (AbstractDriverBasedDataSource) dataSource;
assertThat(urlPredicate.test(adbDataSource.getUrl())).isTrue();
}
}
use of cn.taketoday.jdbc.datasource.AbstractDriverBasedDataSource in project today-framework by TAKETODAY.
the class JdbcNamespaceIntegrationTests method assertCorrectSetupAndCloseContext.
private void assertCorrectSetupAndCloseContext(String file, int count, String... dataSources) {
try (ConfigurableApplicationContext context = context(file)) {
for (String dataSourceName : dataSources) {
DataSource dataSource = context.getBean(dataSourceName, DataSource.class);
assertNumRowsInTestTable(new JdbcTemplate(dataSource), count);
assertThat(dataSource instanceof AbstractDriverBasedDataSource).isTrue();
AbstractDriverBasedDataSource adbDataSource = (AbstractDriverBasedDataSource) dataSource;
assertThat(adbDataSource.getUrl()).contains(dataSourceName);
}
}
}
use of cn.taketoday.jdbc.datasource.AbstractDriverBasedDataSource in project today-framework by TAKETODAY.
the class JdbcNamespaceIntegrationTests method assertCorrectSetupForSingleDataSource.
private void assertCorrectSetupForSingleDataSource(String file, Predicate<String> urlPredicate) {
try (ConfigurableApplicationContext context = context(file)) {
DataSource dataSource = context.getBean(DataSource.class);
assertNumRowsInTestTable(new JdbcTemplate(dataSource), 1);
assertThat(dataSource instanceof AbstractDriverBasedDataSource).isTrue();
AbstractDriverBasedDataSource adbDataSource = (AbstractDriverBasedDataSource) dataSource;
assertThat(urlPredicate.test(adbDataSource.getUrl())).isTrue();
}
}
Aggregations