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
23 import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
24
25 import org.acegisecurity.util.SimpleMethodInvocation;
26
27 import org.aopalliance.intercept.MethodInvocation;
28
29
30
31
32
33
34
35
36 public class InterceptorStatusTokenTests extends TestCase {
37
38
39 public InterceptorStatusTokenTests() {
40 super();
41 }
42
43 public InterceptorStatusTokenTests(String arg0) {
44 super(arg0);
45 }
46
47
48
49 public static void main(String[] args) {
50 junit.textui.TestRunner.run(InterceptorStatusTokenTests.class);
51 }
52
53 public void testNoArgConstructorDoesntExist() {
54 Class clazz = InterceptorStatusToken.class;
55
56 try {
57 clazz.getDeclaredConstructor((Class[]) null);
58 fail("Should have thrown NoSuchMethodException");
59 } catch (NoSuchMethodException expected) {
60 assertTrue(true);
61 }
62 }
63
64 public void testOperation() {
65 ConfigAttributeDefinition attr = new ConfigAttributeDefinition();
66 attr.addConfigAttribute(new SecurityConfig("FOO"));
67
68 MethodInvocation mi = new SimpleMethodInvocation();
69
70 InterceptorStatusToken token = new InterceptorStatusToken(new UsernamePasswordAuthenticationToken("marissa",
71 "koala"), true, attr, mi);
72
73 assertTrue(token.isContextHolderRefreshRequired());
74 assertEquals(attr, token.getAttr());
75 assertEquals(mi, token.getSecureObject());
76 assertEquals("marissa", token.getAuthentication().getPrincipal());
77 }
78 }