RESOLVED - issue SPR-6668: Small Connection leak in DataSourceInitializer

http://jira.springframework.org/browse/SPR-6668
This commit is contained in:
David Syer
2010-01-13 11:00:41 +00:00
parent e195c39d3c
commit e4d8651aa9
3 changed files with 42 additions and 2 deletions

View File

@@ -23,6 +23,18 @@ public class JdbcNamespaceIntegrationTest {
}
}
@Test
public void testCreateEmbeddedDatabaseAgain() throws Exception {
// If Derby isn't cleaned up properly this will fail...
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/jdbc/config/jdbc-config.xml");
try {
assertCorrectSetup(context.getBean("derbyDataSource", DataSource.class));
} finally {
context.close();
}
}
@Test
public void testCreateWithResourcePattern() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(

View File

@@ -2,6 +2,9 @@ package org.springframework.jdbc.datasource.init;
import static org.junit.Assert.assertEquals;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.junit.Test;
@@ -21,7 +24,12 @@ public class DatabasePopulatorTests {
databasePopulator.addScript(resourceLoader.getResource("db-schema-failed-drop-comments.sql"));
databasePopulator.addScript(resourceLoader.getResource("db-test-data.sql"));
databasePopulator.setIgnoreFailedDrops(true);
databasePopulator.populate(db.getConnection());
Connection connection = db.getConnection();
try {
databasePopulator.populate(connection);
} finally {
connection.close();
}
assertDatabaseCreated(db);
db.shutdown();
}