1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.adapters;
17
18 import junit.framework.TestCase;
19
20 import org.acegisecurity.GrantedAuthority;
21 import org.acegisecurity.GrantedAuthorityImpl;
22
23
24 /***
25 * Tests {@link PrincipalAcegiUserToken}.
26 *
27 * @author Ben Alex
28 * @version $Id: PrincipalAcegiUserTokenTests.java,v 1.7 2005/11/25 00:26:29 benalex Exp $
29 */
30 public class PrincipalAcegiUserTokenTests extends TestCase {
31
32
33 public PrincipalAcegiUserTokenTests() {
34 super();
35 }
36
37 public PrincipalAcegiUserTokenTests(String arg0) {
38 super(arg0);
39 }
40
41
42
43 public final void setUp() throws Exception {
44 super.setUp();
45 }
46
47 public static void main(String[] args) {
48 junit.textui.TestRunner.run(PrincipalAcegiUserTokenTests.class);
49 }
50
51 public void testGetters() throws Exception {
52 PrincipalAcegiUserToken token = new PrincipalAcegiUserToken("my_password",
53 "Test", "Password",
54 new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl(
55 "ROLE_TWO")}, null);
56 assertEquals("Test", token.getPrincipal());
57 assertEquals("Password", token.getCredentials());
58 assertEquals("my_password".hashCode(), token.getKeyHash());
59 assertEquals("Test", token.getName());
60 }
61
62 public void testNoArgsConstructor() {
63 try {
64 new PrincipalAcegiUserToken();
65 fail("Should have thrown IllegalArgumentException");
66 } catch (IllegalArgumentException expected) {
67 assertTrue(true);
68 }
69 }
70 }