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.AuthenticationCredentialsNotFoundException;
21  import org.acegisecurity.ConfigAttributeDefinition;
22  
23  import org.acegisecurity.util.SimpleMethodInvocation;
24  
25  
26  /**
27   * Tests {@link AuthenticationCredentialsNotFoundEvent}.
28   *
29   * @author Ben Alex
30   * @version $Id: AuthenticationCredentialsNotFoundEventTests.java 1496 2006-05-23 13:38:33Z benalex $
31   */
32  public class AuthenticationCredentialsNotFoundEventTests extends TestCase {
33      //~ Constructors ===================================================================================================
34  
35      public AuthenticationCredentialsNotFoundEventTests() {
36          super();
37      }
38  
39      public AuthenticationCredentialsNotFoundEventTests(String arg0) {
40          super(arg0);
41      }
42  
43      //~ Methods ========================================================================================================
44  
45      public static void main(String[] args) {
46          junit.textui.TestRunner.run(AuthenticationCredentialsNotFoundEventTests.class);
47      }
48  
49      public void testRejectsNulls() {
50          try {
51              new AuthenticationCredentialsNotFoundEvent(null, new ConfigAttributeDefinition(),
52                  new AuthenticationCredentialsNotFoundException("test"));
53              fail("Should have thrown IllegalArgumentException");
54          } catch (IllegalArgumentException expected) {
55              assertTrue(true);
56          }
57  
58          try {
59              new AuthenticationCredentialsNotFoundEvent(new SimpleMethodInvocation(), null,
60                  new AuthenticationCredentialsNotFoundException("test"));
61              fail("Should have thrown IllegalArgumentException");
62          } catch (IllegalArgumentException expected) {
63              assertTrue(true);
64          }
65  
66          try {
67              new AuthenticationCredentialsNotFoundEvent(new SimpleMethodInvocation(), new ConfigAttributeDefinition(),
68                  null);
69              fail("Should have thrown IllegalArgumentException");
70          } catch (IllegalArgumentException expected) {
71              assertTrue(true);
72          }
73      }
74  }