01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /**
19: * @author Maxim V. Makarov
20: * @version $Revision$
21: */package javax.security.auth;
22:
23: import junit.framework.TestCase;
24:
25: /**
26: * Tests AuthPermission class
27: */
28: public class AuthPermissionTest extends TestCase {
29:
30: private AuthPermission ap;
31: private AuthPermission ap1;
32:
33: @Override
34: protected void setUp() throws Exception {
35: ap = new AuthPermission("name");
36: ap1 = new AuthPermission("createLoginContext");
37: }
38:
39: /**
40: * Constructor for AuthPermissionTest.
41: *
42: * @param name
43: */
44: public AuthPermissionTest(String name) {
45: super (name);
46: }
47:
48: /**
49: * The target name "createLoginContext" is deprecated
50: * and it should be replaced by "createLoginContext.*"
51: */
52: public void testConstructor_01() {
53: assertEquals("createLoginContext.*", ap1.getName());
54: }
55:
56: /**
57: * Checks that target name is correct
58: */
59: public void testConstructor_02() {
60: assertEquals("name", ap.getName());
61: }
62:
63: /**
64: * Target name should not be null
65: */
66: public void testConstructor_03() {
67: try {
68: ap = new AuthPermission(null);
69: fail("no expected NPE");
70: } catch (NullPointerException e) {
71: }
72: }
73:
74: /**
75: * Action should be ignored
76: */
77: public void testConstructor_04() {
78: try {
79: ap = new AuthPermission("name", null);
80: ap = new AuthPermission("name", "read");
81: } catch (NullPointerException e) {
82: fail("action is not ignored");
83: }
84: }
85:
86: /**
87: * the target name "createLoginContext.{name}" is correct
88: */
89: public void testConstructor_05() {
90: ap1 = new AuthPermission("createLoginContext.name");
91: assertEquals("createLoginContext.name", ap1.getName());
92: }
93:
94: }
|