add back HSQL db in test dir, as it turns out _it is_ supposed to be in CVS
modify JdbcDaoTests to test for role prefix functionality fix glitch in JdbcDaoImpl modify Eclipse classpath so HSQL lib is loaded, so unit tests can run in Eclipse as well.
This commit is contained in:
@@ -105,6 +105,17 @@ public class JdbcDaoTests extends TestCase {
|
||||
assertEquals("wombat", dao.loadUserByUsername("ScOTt").getPassword());
|
||||
}
|
||||
|
||||
public void testRolePrefixWorks() throws Exception {
|
||||
JdbcDaoImpl dao = makePopulatedJdbcDaoWithRolePrefix();
|
||||
User user = dao.loadUserByUsername("marissa");
|
||||
assertEquals("marissa", user.getUsername());
|
||||
assertEquals("ARBITRARY_PREFIX_ROLE_TELLER",
|
||||
user.getAuthorities()[0].getAuthority());
|
||||
assertEquals("ARBITRARY_PREFIX_ROLE_SUPERVISOR",
|
||||
user.getAuthorities()[1].getAuthority());
|
||||
assertEquals(2, user.getAuthorities().length);
|
||||
}
|
||||
|
||||
public void testStartupFailsIfDataSourceNotSet() throws Exception {
|
||||
JdbcDaoImpl dao = new JdbcDaoImpl();
|
||||
|
||||
@@ -141,4 +152,20 @@ public class JdbcDaoTests extends TestCase {
|
||||
|
||||
return dao;
|
||||
}
|
||||
|
||||
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.setRolePrefix("ARBITRARY_PREFIX_");
|
||||
dao.afterPropertiesSet();
|
||||
|
||||
return dao;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user