|
@@ -20,12 +20,18 @@ import junit.framework.TestCase;
|
|
import net.sf.acegisecurity.providers.dao.UserDetails;
|
|
import net.sf.acegisecurity.providers.dao.UserDetails;
|
|
import net.sf.acegisecurity.providers.dao.UsernameNotFoundException;
|
|
import net.sf.acegisecurity.providers.dao.UsernameNotFoundException;
|
|
|
|
|
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
|
+
|
|
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
|
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
|
import org.springframework.jdbc.object.MappingSqlQuery;
|
|
import org.springframework.jdbc.object.MappingSqlQuery;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+
|
|
import java.sql.ResultSet;
|
|
import java.sql.ResultSet;
|
|
import java.sql.SQLException;
|
|
import java.sql.SQLException;
|
|
|
|
|
|
|
|
+import javax.sql.DataSource;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* Tests {@link JdbcDaoImpl}.
|
|
* Tests {@link JdbcDaoImpl}.
|
|
@@ -161,14 +167,8 @@ public class JdbcDaoTests extends TestCase {
|
|
}
|
|
}
|
|
|
|
|
|
private JdbcDaoImpl makePopulatedJdbcDao() throws Exception {
|
|
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();
|
|
JdbcDaoImpl dao = new JdbcDaoImpl();
|
|
- dao.setDataSource(ds);
|
|
|
|
|
|
+ dao.setDataSource(makeDataSource());
|
|
dao.afterPropertiesSet();
|
|
dao.afterPropertiesSet();
|
|
|
|
|
|
return dao;
|
|
return dao;
|
|
@@ -176,20 +176,28 @@ public class JdbcDaoTests extends TestCase {
|
|
|
|
|
|
private JdbcDaoImpl makePopulatedJdbcDaoWithRolePrefix()
|
|
private JdbcDaoImpl makePopulatedJdbcDaoWithRolePrefix()
|
|
throws Exception {
|
|
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();
|
|
JdbcDaoImpl dao = new JdbcDaoImpl();
|
|
- dao.setDataSource(ds);
|
|
|
|
|
|
+ dao.setDataSource(makeDataSource());
|
|
dao.setRolePrefix("ARBITRARY_PREFIX_");
|
|
dao.setRolePrefix("ARBITRARY_PREFIX_");
|
|
dao.afterPropertiesSet();
|
|
dao.afterPropertiesSet();
|
|
|
|
|
|
return dao;
|
|
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 ==========================================================
|
|
//~ Inner Classes ==========================================================
|
|
|
|
|
|
private class MockMappingSqlQuery extends MappingSqlQuery {
|
|
private class MockMappingSqlQuery extends MappingSqlQuery {
|