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 import org.acegisecurity.event.authorization.AuthorizationFailureEvent;
23 import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
24 import org.acegisecurity.util.SimpleMethodInvocation;
25
26
27 /***
28 * Tests {@link AuthorizationFailureEvent}.
29 *
30 * @author Ben Alex
31 * @version $Id: AuthorizationFailureEventTests.java,v 1.3 2005/11/25 04:17:24 benalex Exp $
32 */
33 public class AuthorizationFailureEventTests extends TestCase {
34
35
36 public AuthorizationFailureEventTests() {
37 super();
38 }
39
40 public AuthorizationFailureEventTests(String arg0) {
41 super(arg0);
42 }
43
44
45
46 public static void main(String[] args) {
47 junit.textui.TestRunner.run(AuthorizationFailureEventTests.class);
48 }
49
50 public void testRejectsNulls() {
51 try {
52 new AuthorizationFailureEvent(null,
53 new ConfigAttributeDefinition(),
54 new UsernamePasswordAuthenticationToken("foo", "bar"),
55 new AccessDeniedException("error"));
56 fail("Should have thrown IllegalArgumentException");
57 } catch (IllegalArgumentException expected) {
58 assertTrue(true);
59 }
60
61 try {
62 new AuthorizationFailureEvent(new SimpleMethodInvocation(), null,
63 new UsernamePasswordAuthenticationToken("foo", "bar"),
64 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(),
72 new ConfigAttributeDefinition(), null,
73 new AccessDeniedException("error"));
74 fail("Should have thrown IllegalArgumentException");
75 } catch (IllegalArgumentException expected) {
76 assertTrue(true);
77 }
78
79 try {
80 new AuthorizationFailureEvent(new SimpleMethodInvocation(),
81 new ConfigAttributeDefinition(),
82 new UsernamePasswordAuthenticationToken("foo", "bar"), null);
83 fail("Should have thrown IllegalArgumentException");
84 } catch (IllegalArgumentException expected) {
85 assertTrue(true);
86 }
87 }
88 }