1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.intercept;
17
18 import junit.framework.TestCase;
19
20 import org.acegisecurity.ConfigAttributeDefinition;
21 import org.acegisecurity.SecurityConfig;
22 import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
23 import org.acegisecurity.util.SimpleMethodInvocation;
24
25 import org.aopalliance.intercept.MethodInvocation;
26
27
28 /***
29 * Tests {@link InterceptorStatusToken}.
30 *
31 * @author Ben Alex
32 * @version $Id: InterceptorStatusTokenTests.java,v 1.3 2005/11/25 04:17:24 benalex Exp $
33 */
34 public class InterceptorStatusTokenTests extends TestCase {
35
36
37 public InterceptorStatusTokenTests() {
38 super();
39 }
40
41 public InterceptorStatusTokenTests(String arg0) {
42 super(arg0);
43 }
44
45
46
47 public static void main(String[] args) {
48 junit.textui.TestRunner.run(InterceptorStatusTokenTests.class);
49 }
50
51 public void testDefaultConstructor() {
52 try {
53 new InterceptorStatusToken();
54 fail("Should have thrown IllegalArgumentException");
55 } catch (IllegalArgumentException expected) {
56 assertTrue(true);
57 }
58 }
59
60 public void testOperation() {
61 ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
62 attr.addConfigAttribute(new SecurityConfig("FOO"));
63
64 MethodInvocation mi = new SimpleMethodInvocation();
65
66 InterceptorStatusToken token = new InterceptorStatusToken(new UsernamePasswordAuthenticationToken(
67 "marissa", "koala"), true, attr, mi);
68
69 assertTrue(token.isContextHolderRefreshRequired());
70 assertEquals(attr, token.getAttr());
71 assertEquals(mi, token.getSecureObject());
72 assertEquals("marissa", token.getAuthentication().getPrincipal());
73 }
74 }