use of javax.sql.DataSource in project spring-framework by spring-projects.
the class InitializeDatabaseIntegrationTests method testDisableCreateEmbeddedDatabase.
@Test(expected = BadSqlGrammarException.class)
public void testDisableCreateEmbeddedDatabase() throws Exception {
System.setProperty("ENABLED", "false");
context = new ClassPathXmlApplicationContext("org/springframework/jdbc/config/jdbc-initialize-config.xml");
assertCorrectSetup(context.getBean("dataSource", DataSource.class));
}
use of javax.sql.DataSource in project spring-framework by spring-projects.
the class InitializeDatabaseIntegrationTests method testCreateEmbeddedDatabase.
@Test
public void testCreateEmbeddedDatabase() throws Exception {
context = new ClassPathXmlApplicationContext("org/springframework/jdbc/config/jdbc-initialize-config.xml");
assertCorrectSetup(context.getBean("dataSource", DataSource.class));
}
use of javax.sql.DataSource in project spring-framework by spring-projects.
the class JdbcNamespaceIntegrationTests method createAndDestroy.
@Test
public void createAndDestroy() throws Exception {
ClassPathXmlApplicationContext context = context("jdbc-destroy-config.xml");
try {
DataSource dataSource = context.getBean(DataSource.class);
JdbcTemplate template = new JdbcTemplate(dataSource);
assertNumRowsInTestTable(template, 1);
context.getBean(DataSourceInitializer.class).destroy();
// Table has been dropped
expected.expect(BadSqlGrammarException.class);
assertNumRowsInTestTable(template, 1);
} finally {
context.close();
}
}
use of javax.sql.DataSource in project spring-framework by spring-projects.
the class JdbcNamespaceIntegrationTests method createAndDestroyNestedWithH2.
@Test
public void createAndDestroyNestedWithH2() throws Exception {
ClassPathXmlApplicationContext context = context("jdbc-destroy-nested-config-h2.xml");
try {
DataSource dataSource = context.getBean(DataSource.class);
JdbcTemplate template = new JdbcTemplate(dataSource);
assertNumRowsInTestTable(template, 1);
context.getBean(EmbeddedDatabaseFactoryBean.class).destroy();
// Table has been dropped
expected.expect(BadSqlGrammarException.class);
assertNumRowsInTestTable(template, 1);
} finally {
context.close();
}
}
use of javax.sql.DataSource in project spring-framework by spring-projects.
the class DataSourceUtils method getConnectionSynchronizationOrder.
/**
* Determine the connection synchronization order to use for the given
* DataSource. Decreased for every level of nesting that a DataSource
* has, checked through the level of DelegatingDataSource nesting.
* @param dataSource the DataSource to check
* @return the connection synchronization order to use
* @see #CONNECTION_SYNCHRONIZATION_ORDER
*/
private static int getConnectionSynchronizationOrder(DataSource dataSource) {
int order = CONNECTION_SYNCHRONIZATION_ORDER;
DataSource currDs = dataSource;
while (currDs instanceof DelegatingDataSource) {
order--;
currDs = ((DelegatingDataSource) currDs).getTargetDataSource();
}
return order;
}
Aggregations