Skip to content

Commit 17887d2

Browse files
committed
RESOLVED - issue SPR-6365: spring-jdbc.xsd script element claims resource patterns can be used for any SQL resource location but this is only supported for initialize-database tag
Grr: classpath*: again...
1 parent 7519162 commit 17887d2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

org.springframework.jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTest.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,24 @@ public class JdbcNamespaceIntegrationTest {
1414
public void testCreateEmbeddedDatabase() throws Exception {
1515
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
1616
"org/springframework/jdbc/config/jdbc-config.xml");
17-
assertCorrectSetup(context.getBean("dataSource", DataSource.class));
18-
assertCorrectSetup(context.getBean("h2DataSource", DataSource.class));
19-
assertCorrectSetup(context.getBean("derbyDataSource", DataSource.class));
20-
context.close();
17+
try {
18+
assertCorrectSetup(context.getBean("dataSource", DataSource.class));
19+
assertCorrectSetup(context.getBean("h2DataSource", DataSource.class));
20+
assertCorrectSetup(context.getBean("derbyDataSource", DataSource.class));
21+
} finally {
22+
context.close();
23+
}
2124
}
2225

2326
@Test
2427
public void testCreateWithResourcePattern() throws Exception {
2528
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
2629
"org/springframework/jdbc/config/jdbc-config-pattern.xml");
27-
assertCorrectSetup(context.getBean("dataSource", DataSource.class));
28-
context.close();
30+
try {
31+
assertCorrectSetup(context.getBean("dataSource", DataSource.class));
32+
} finally {
33+
context.close();
34+
}
2935
}
3036

3137
private void assertCorrectSetup(DataSource dataSource) {

org.springframework.jdbc/src/test/resources/org/springframework/jdbc/config/jdbc-config-pattern.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
66
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
77

8-
<jdbc:embedded-database id="dataSource">
8+
<jdbc:embedded-database id="dataSource" type="HSQL">
99
<jdbc:script location="classpath:org/springframework/jdbc/config/db-schema.sql"/>
10-
<jdbc:script location="classpath:org/springframework/jdbc/config/*-data.sql"/>
10+
<jdbc:script location="classpath*:org/springframework/jdbc/config/*-data.sql"/>
1111
</jdbc:embedded-database>
1212

1313
</beans>

0 commit comments

Comments
 (0)