1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.event.authorization;
17
18 import junit.framework.TestCase;
19
20 import org.acegisecurity.AccessDeniedException;
21 import org.acegisecurity.ConfigAttributeDefinition;
22
23 import org.acegisecurity.event.authorization.AuthorizationFailureEvent;
24
25 import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
26
27 import org.acegisecurity.util.SimpleMethodInvocation;
28
29
30
31
32
33
34
35
36 public class AuthorizationFailureEventTests extends TestCase {
37
38
39 public AuthorizationFailureEventTests() {
40 super();
41 }
42
43 public AuthorizationFailureEventTests(String arg0) {
44 super(arg0);
45 }
46
47
48
49 public static void main(String[] args) {
50 junit.textui.TestRunner.run(AuthorizationFailureEventTests.class);
51 }
52
53 public void testRejectsNulls() {
54 try {
55 new AuthorizationFailureEvent(null, new ConfigAttributeDefinition(),
56 new UsernamePasswordAuthenticationToken("foo", "bar"), new AccessDeniedException("error"));
57 fail("Should have thrown IllegalArgumentException");
58 } catch (IllegalArgumentException expected) {
59 assertTrue(true);
60 }
61
62 try {
63 new AuthorizationFailureEvent(new SimpleMethodInvocation(), null,
64 new UsernamePasswordAuthenticationToken("foo", "bar"), new AccessDeniedException("error"));
65 fail("Should have thrown IllegalArgumentException");
66 } catch (IllegalArgumentException expected) {
67 assertTrue(true);
68 }
69
70 try {
71 new AuthorizationFailureEvent(new SimpleMethodInvocation(), new ConfigAttributeDefinition(), null,
72 new AccessDeniedException("error"));
73 fail("Should have thrown IllegalArgumentException");
74 } catch (IllegalArgumentException expected) {
75 assertTrue(true);
76 }
77
78 try {
79 new AuthorizationFailureEvent(new SimpleMethodInvocation(), new ConfigAttributeDefinition(),
80 new UsernamePasswordAuthenticationToken("foo", "bar"), null);
81 fail("Should have thrown IllegalArgumentException");
82 } catch (IllegalArgumentException expected) {
83 assertTrue(true);
84 }
85 }
86 }