Detect nulls within GrantedAuthority[] passed to constructor. This ensures end-user DAO implementations are creating the User correctly.

This commit is contained in:
Ben Alex
2004-04-18 11:23:01 +00:00
parent a0f809991d
commit f38ed01b29
2 changed files with 23 additions and 0 deletions

View File

@@ -84,6 +84,19 @@ public class UserTests extends TestCase {
}
}
public void testNullWithinGrantedAuthorityElementIsRejected()
throws Exception {
try {
User user = new User(null, "koala", true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl(
"ROLE_TWO"), null, new GrantedAuthorityImpl(
"ROLE_THREE")});
fail("Should have thrown IllegalArgumentException");
} catch (IllegalArgumentException expected) {
assertTrue(true);
}
}
public void testUserGettersSetter() throws Exception {
User user = new User("marissa", "koala", true,
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl(