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 Alexey V. Varlamov
20: * @version $Revision$
21: */package org.apache.harmony.security.tests.java.security;
22:
23: import java.security.*;
24: import junit.framework.TestCase;
25:
26: /**
27: * Tests for <code>SecurityPermission</code>
28: *
29: */
30: public class SecurityPermissionTest extends TestCase {
31:
32: public static void main(String[] args) {
33: junit.textui.TestRunner.run(SecurityPermissionTest.class);
34: }
35:
36: /**
37: * Constructor for SecurityPermissionTest.
38: * @param arg0
39: */
40: public SecurityPermissionTest(String arg0) {
41: super (arg0);
42: }
43:
44: /**
45: * Check all constructors: an object is created with the specified valid name.
46: * If name equal null then NPE should be thrown.
47: * If name is empty then IAE should be thrown.
48: * Action is ignored.
49: */
50: public void testCtor() {
51: String name = "basic123*$%#";
52: SecurityPermission test = new SecurityPermission(name);
53: assertEquals(name, test.getName());
54: assertEquals("", test.getActions());
55: test = new SecurityPermission(name, "#$!#12435");
56: assertEquals(name, test.getName());
57: assertEquals("", test.getActions());
58: try {
59: new SecurityPermission(null);
60: fail("NPE is not thrown");
61: } catch (NullPointerException ok) {
62: }
63:
64: try {
65: new SecurityPermission(null, "ds235");
66: fail("NPE is not thrown");
67: } catch (NullPointerException ok) {
68: }
69:
70: try {
71: new SecurityPermission("");
72: fail("IAE is not thrown");
73: } catch (IllegalArgumentException ok) {
74: }
75: try {
76: new SecurityPermission("", "ertre 3454");
77: fail("IAE is not thrown");
78: } catch (IllegalArgumentException ok) {
79: }
80: }
81: }
|