1   /* Copyright 2004 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.runas;
17  
18  import junit.framework.TestCase;
19  
20  import org.acegisecurity.SecurityConfig;
21  
22  
23  /***
24   * Tests {@link NullRunAsManager}.
25   *
26   * @author Ben Alex
27   * @version $Id: NullRunAsManagerTests.java,v 1.2 2005/11/17 00:56:28 benalex Exp $
28   */
29  public class NullRunAsManagerTests extends TestCase {
30      //~ Constructors ===========================================================
31  
32      public NullRunAsManagerTests() {
33          super();
34      }
35  
36      public NullRunAsManagerTests(String arg0) {
37          super(arg0);
38      }
39  
40      //~ Methods ================================================================
41  
42      public final void setUp() throws Exception {
43          super.setUp();
44      }
45  
46      public static void main(String[] args) {
47          junit.textui.TestRunner.run(NullRunAsManagerTests.class);
48      }
49  
50      public void testAlwaysReturnsNull() {
51          NullRunAsManager runAs = new NullRunAsManager();
52          assertNull(runAs.buildRunAs(null, null, null));
53      }
54  
55      public void testAlwaysSupportsClass() {
56          NullRunAsManager runAs = new NullRunAsManager();
57          assertTrue(runAs.supports(String.class));
58      }
59  
60      public void testNeverSupportsAttribute() {
61          NullRunAsManager runAs = new NullRunAsManager();
62          assertFalse(runAs.supports(new SecurityConfig("X")));
63      }
64  }