Add toString() method and test.

This commit is contained in:
Ben Alex 2004-04-23 06:27:50 +00:00
parent e0d57de330
commit ed68b701b2
2 changed files with 17 additions and 0 deletions

View File

@ -145,4 +145,12 @@ public class DaoAuthenticationToken extends AbstractAuthenticationToken
return false;
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(super.toString());
sb.append("; Expires: " + this.expires.toString());
return sb.toString();
}
}

View File

@ -214,4 +214,13 @@ public class DaoAuthenticationTokenTests extends TestCase {
token.setAuthenticated(false); // ignored
assertTrue(token.isAuthenticated());
}
public void testToString() {
DaoAuthenticationToken token = new DaoAuthenticationToken("key",
new Date(), "Test", "Password",
new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl(
"ROLE_TWO")});
String result = token.toString();
assertTrue(result.lastIndexOf("Expires:") != -1);
}
}