Java Code Examples for org.springframework.jdbc.datasource.AbstractDriverBasedDataSource

The following examples show how to use org.springframework.jdbc.datasource.AbstractDriverBasedDataSource. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void assertCorrectSetupAndCloseContext(String file, int count, String... dataSources) {
	ConfigurableApplicationContext context = context(file);
	try {
		for (String dataSourceName : dataSources) {
			DataSource dataSource = context.getBean(dataSourceName, DataSource.class);
			assertNumRowsInTestTable(new JdbcTemplate(dataSource), count);
			assertTrue(dataSource instanceof AbstractDriverBasedDataSource);
			AbstractDriverBasedDataSource adbDataSource = (AbstractDriverBasedDataSource) dataSource;
			assertThat(adbDataSource.getUrl(), containsString(dataSourceName));
		}
	}
	finally {
		context.close();
	}
}
 
Example 2
private void assertCorrectSetupForSingleDataSource(String file, Predicate<String> urlPredicate) {
	ConfigurableApplicationContext context = context(file);
	try {
		DataSource dataSource = context.getBean(DataSource.class);
		assertNumRowsInTestTable(new JdbcTemplate(dataSource), 1);
		assertTrue(dataSource instanceof AbstractDriverBasedDataSource);
		AbstractDriverBasedDataSource adbDataSource = (AbstractDriverBasedDataSource) dataSource;
		assertTrue(urlPredicate.test(adbDataSource.getUrl()));
	}
	finally {
		context.close();
	}
}
 
Example 3
private void assertCorrectSetupAndCloseContext(String file, int count, String... dataSources) {
	ConfigurableApplicationContext context = context(file);
	try {
		for (String dataSourceName : dataSources) {
			DataSource dataSource = context.getBean(dataSourceName, DataSource.class);
			assertNumRowsInTestTable(new JdbcTemplate(dataSource), count);
			assertTrue(dataSource instanceof AbstractDriverBasedDataSource);
			AbstractDriverBasedDataSource adbDataSource = (AbstractDriverBasedDataSource) dataSource;
			assertThat(adbDataSource.getUrl(), containsString(dataSourceName));
		}
	}
	finally {
		context.close();
	}
}
 
Example 4
private void assertCorrectSetupForSingleDataSource(String file, Predicate<String> urlPredicate) {
	ConfigurableApplicationContext context = context(file);
	try {
		DataSource dataSource = context.getBean(DataSource.class);
		assertNumRowsInTestTable(new JdbcTemplate(dataSource), 1);
		assertTrue(dataSource instanceof AbstractDriverBasedDataSource);
		AbstractDriverBasedDataSource adbDataSource = (AbstractDriverBasedDataSource) dataSource;
		assertTrue(urlPredicate.test(adbDataSource.getUrl()));
	}
	finally {
		context.close();
	}
}
 
Example 5
private void assertCorrectSetupAndCloseContext(String file, int count, String... dataSources) {
	ConfigurableApplicationContext context = context(file);
	try {
		for (String dataSourceName : dataSources) {
			DataSource dataSource = context.getBean(dataSourceName, DataSource.class);
			assertNumRowsInTestTable(new JdbcTemplate(dataSource), count);
			assertTrue(dataSource instanceof AbstractDriverBasedDataSource);
			AbstractDriverBasedDataSource adbDataSource = (AbstractDriverBasedDataSource) dataSource;
			assertThat(adbDataSource.getUrl(), containsString(dataSourceName));
		}
	}
	finally {
		context.close();
	}
}
 
Example 6
private void assertCorrectSetupForSingleDataSource(String file, Predicate<String> urlPredicate) {
	ConfigurableApplicationContext context = context(file);
	try {
		DataSource dataSource = context.getBean(DataSource.class);
		assertNumRowsInTestTable(new JdbcTemplate(dataSource), 1);
		assertTrue(dataSource instanceof AbstractDriverBasedDataSource);
		AbstractDriverBasedDataSource adbDataSource = (AbstractDriverBasedDataSource) dataSource;
		assertTrue(urlPredicate.test(adbDataSource.getUrl()));
	}
	finally {
		context.close();
	}
}