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:
Colin Sampaleanu
2004-04-15 03:34:18 +00:00
parent 18d5c59532
commit 41a837f8cd
9 changed files with 150 additions and 12 deletions

View File

@@ -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;
}
}