Convert database URL to use absolute path. Fixes test with Maven.

This commit is contained in:
Luke Taylor 2004-07-02 14:07:26 +00:00
parent ce712eaccf
commit b957b5e25b
1 changed files with 22 additions and 14 deletions

View File

@ -20,12 +20,18 @@ import junit.framework.TestCase;
import net.sf.acegisecurity.providers.dao.UserDetails;
import net.sf.acegisecurity.providers.dao.UsernameNotFoundException;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.object.MappingSqlQuery;
import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
/**
* Tests {@link JdbcDaoImpl}.
@ -161,14 +167,8 @@ public class JdbcDaoTests extends TestCase {
}
private JdbcDaoImpl makePopulatedJdbcDao() throws Exception {
DriverManagerDataSource ds = new DriverManagerDataSource();
ds.setDriverClassName("org.hsqldb.jdbcDriver");
ds.setUrl("jdbc:hsqldb:acegisecuritytest");
ds.setUsername("sa");
ds.setPassword("");
JdbcDaoImpl dao = new JdbcDaoImpl();
dao.setDataSource(ds);
dao.setDataSource(makeDataSource());
dao.afterPropertiesSet();
return dao;
@ -176,20 +176,28 @@ public class JdbcDaoTests extends TestCase {
private JdbcDaoImpl makePopulatedJdbcDaoWithRolePrefix()
throws Exception {
DriverManagerDataSource ds = new DriverManagerDataSource();
ds.setDriverClassName("org.hsqldb.jdbcDriver");
ds.setUrl("jdbc:hsqldb:acegisecuritytest");
ds.setUsername("sa");
ds.setPassword("");
JdbcDaoImpl dao = new JdbcDaoImpl();
dao.setDataSource(ds);
dao.setDataSource(makeDataSource());
dao.setRolePrefix("ARBITRARY_PREFIX_");
dao.afterPropertiesSet();
return dao;
}
private DataSource makeDataSource()
throws Exception {
ClassPathResource dbScript = new ClassPathResource("acegisecuritytest.script");
String path = dbScript.getFile().getParentFile().getAbsolutePath();
DriverManagerDataSource ds = new DriverManagerDataSource();
ds.setDriverClassName("org.hsqldb.jdbcDriver");
ds.setUrl("jdbc:hsqldb:" + path + File.separator + "acegisecuritytest");
ds.setUsername("sa");
ds.setPassword("");
return ds;
}
//~ Inner Classes ==========================================================
private class MockMappingSqlQuery extends MappingSqlQuery {