소스 검색

Add toString() method and test.

Ben Alex 21 년 전
부모
커밋
ed68b701b2

+ 8 - 0
core/src/main/java/org/acegisecurity/providers/dao/DaoAuthenticationToken.java

@@ -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();
+    }
 }

+ 9 - 0
core/src/test/java/org/acegisecurity/providers/dao/DaoAuthenticationTokenTests.java

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