1   /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
2    *
3    * Licensed under the Apache License, Version 2.0 (the "License");
4    * you may not use this file except in compliance with the License.
5    * You may obtain a copy of the License at
6    *
7    *     http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * 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  /**
28   * Tests {@link AuthorizedEvent}.
29   *
30   * @author Ben Alex
31   * @version $Id: AuthorizedEventTests.java 1496 2006-05-23 13:38:33Z benalex $
32   */
33  public class AuthorizedEventTests extends TestCase {
34      //~ Constructors ===================================================================================================
35  
36      public AuthorizedEventTests() {
37          super();
38      }
39  
40      public AuthorizedEventTests(String arg0) {
41          super(arg0);
42      }
43  
44      //~ Methods ========================================================================================================
45  
46      public static void main(String[] args) {
47          junit.textui.TestRunner.run(AuthorizedEventTests.class);
48      }
49  
50      public void testRejectsNulls() {
51          try {
52              new AuthorizedEvent(null, new ConfigAttributeDefinition(),
53                  new UsernamePasswordAuthenticationToken("foo", "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", "bar"));
62              fail("Should have thrown IllegalArgumentException");
63          } catch (IllegalArgumentException expected) {
64              assertTrue(true);
65          }
66  
67          try {
68              new AuthorizedEvent(new SimpleMethodInvocation(), new ConfigAttributeDefinition(), null);
69              fail("Should have thrown IllegalArgumentException");
70          } catch (IllegalArgumentException expected) {
71              assertTrue(true);
72          }
73      }
74  }