1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.adapters.jetty;
17
18 import junit.framework.TestCase;
19
20 import org.acegisecurity.GrantedAuthority;
21 import org.acegisecurity.GrantedAuthorityImpl;
22
23
24 /***
25 * Tests {@link JettyAcegiUserToken}.
26 *
27 * @author Ben Alex
28 * @version $Id: JettyAcegiUserTokenTests.java,v 1.3 2005/11/17 00:56:29 benalex Exp $
29 */
30 public class JettyAcegiUserTokenTests extends TestCase {
31
32
33 public JettyAcegiUserTokenTests() {
34 super();
35 }
36
37 public JettyAcegiUserTokenTests(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(JettyAcegiUserTokenTests.class);
49 }
50
51 public void testGetters() throws Exception {
52 JettyAcegiUserToken token = new JettyAcegiUserToken("my_password",
53 "Test", "Password",
54 new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl(
55 "ROLE_TWO")});
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 JettyAcegiUserToken();
65 fail("Should have thrown IllegalArgumentException");
66 } catch (IllegalArgumentException expected) {
67 assertTrue(true);
68 }
69 }
70 }