spring-jdbc xsd initial commit; includes embedded-database tag

This commit is contained in:
Keith Donald
2009-05-08 19:06:58 +00:00
parent 3e9b9a8a2a
commit 6cec37ac7f
7 changed files with 179 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
package org.springframework.jdbc.config;
import static org.junit.Assert.assertEquals;
import javax.sql.DataSource;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
public class JdbcNamespaceIntegrationTest {
@Test
public void testCreateEmbeddedDatabase() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("org/springframework/jdbc/config/jdbc-config.xml");
DataSource ds = context.getBean("dataSource", DataSource.class);
JdbcTemplate t = new JdbcTemplate(ds);
assertEquals(1, t.queryForInt("select count(*) from T_TEST"));
}
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
<jdbc:embedded-database id="dataSource" type="HSQL">
<jdbc:script location="classpath:org/springframework/jdbc/datasource/embedded/db-schema.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/datasource/embedded/db-test-data.sql"/>
</jdbc:embedded-database>
</beans>