This commit is contained in:
Keith Donald 2009-04-23 19:01:41 +00:00
parent 3a457dcec9
commit 37e1333a41
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package org.springframework.jdbc.datasource.embedded;
import static org.junit.Assert.assertEquals;
import javax.sql.DataSource;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.core.JdbcTemplate;
public class EmbeddedDatabaseFactoryBeanTests {
@Test
public void testFactoryBeanLifecycle() throws Exception {
EmbeddedDatabaseFactoryBean bean = new EmbeddedDatabaseFactoryBean();
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
populator.addScript(new ClassPathResource("db-schema.sql", getClass()));
populator.addScript(new ClassPathResource("db-test-data.sql", getClass()));
bean.setDatabasePopulator(populator);
bean.afterPropertiesSet();
DataSource ds = bean.getObject();
JdbcTemplate template = new JdbcTemplate(ds);
assertEquals("Keith", template.queryForObject("select NAME from T_TEST", String.class));
bean.destroy();
}
}