01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity.event.authorization;
17:
18: import junit.framework.TestCase;
19:
20: import org.acegisecurity.ConfigAttributeDefinition;
21:
22: import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
23:
24: import org.acegisecurity.util.SimpleMethodInvocation;
25:
26: /**
27: * Tests {@link AuthorizedEvent}.
28: *
29: * @author Ben Alex
30: * @version $Id: AuthorizedEventTests.java 1496 2006-05-23 13:38:33Z benalex $
31: */
32: public class AuthorizedEventTests extends TestCase {
33: //~ Constructors ===================================================================================================
34:
35: public AuthorizedEventTests() {
36: super ();
37: }
38:
39: public AuthorizedEventTests(String arg0) {
40: super (arg0);
41: }
42:
43: //~ Methods ========================================================================================================
44:
45: public static void main(String[] args) {
46: junit.textui.TestRunner.run(AuthorizedEventTests.class);
47: }
48:
49: public void testRejectsNulls() {
50: try {
51: new AuthorizedEvent(null, new ConfigAttributeDefinition(),
52: new UsernamePasswordAuthenticationToken("foo",
53: "bar"));
54: fail("Should have thrown IllegalArgumentException");
55: } catch (IllegalArgumentException expected) {
56: assertTrue(true);
57: }
58:
59: try {
60: new AuthorizedEvent(new SimpleMethodInvocation(), null,
61: new UsernamePasswordAuthenticationToken("foo",
62: "bar"));
63: fail("Should have thrown IllegalArgumentException");
64: } catch (IllegalArgumentException expected) {
65: assertTrue(true);
66: }
67:
68: try {
69: new AuthorizedEvent(new SimpleMethodInvocation(),
70: new ConfigAttributeDefinition(), null);
71: fail("Should have thrown IllegalArgumentException");
72: } catch (IllegalArgumentException expected) {
73: assertTrue(true);
74: }
75: }
76: }
|