test datasource factory initial commit; needs review from Juergen on how to best make DataSource available as a Spring bean when desired

This commit is contained in:
Keith Donald
2009-04-21 21:31:16 +00:00
parent 4d509cebdb
commit b8b74db01a
10 changed files with 436 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
package org.springframework.test.jdbc;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
public class TestDataSourceFactoryTests {
TestDataSourceFactory factory = new TestDataSourceFactory();
@Test
public void testGetDataSource() {
StubTestDataSourcePopulator populator = new StubTestDataSourcePopulator();
factory.setDatabasePopulator(populator);
factory.getDataSource();
assertTrue(populator.populateCalled);
factory.destroyDataSource();
}
private static class StubTestDataSourcePopulator implements TestDatabasePopulator {
private boolean populateCalled;
public void populate(JdbcTemplate template) throws DataAccessException {
this.populateCalled = true;
}
}
}