blob: 806ae941998804b126645bc8023d17ac6bd11c74 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/*
25 * @test
26 * @bug 5057136
27 * @summary Generify sun.security.action.GetPropertyAction and friends
28 */
29
30import java.io.*;
31import java.security.*;
32import sun.security.action.*;
33
34public class Generify {
35
36 public static void main(String[] args) throws Exception {
37
38 long larg = 1234567890L;
39
40 System.setProperty("boolean", "true");
41 System.setProperty("integer", "9");
42 System.setProperty("long", Long.toString(larg));
43 System.setProperty("property", "propertyvalue");
44
45 Boolean b = AccessController.doPrivileged
46 (new GetBooleanAction("boolean"));
47 if (b.booleanValue() == true) {
48 System.out.println("boolean test passed");
49 } else {
50 throw new SecurityException("boolean test failed");
51 }
52
53 Integer i = AccessController.doPrivileged
54 (new GetIntegerAction("integer"));
55 if (i.intValue() == 9) {
56 System.out.println("integer test passed");
57 } else {
58 throw new SecurityException("integer test failed");
59 }
60
61 Long l = AccessController.doPrivileged
62 (new GetLongAction("long"));
63 if (l.longValue() == larg) {
64 System.out.println("long test passed");
65 } else {
66 throw new SecurityException("long test failed");
67 }
68
69 String prop = AccessController.doPrivileged
70 (new GetPropertyAction("property"));
71 if (prop.equals("propertyvalue")) {
72 System.out.println("property test passed");
73 } else {
74 throw new SecurityException("property test failed");
75 }
76
77 File f = new File(System.getProperty("test.src", "."), "Generify.java");
78 FileInputStream fis = AccessController.doPrivileged
79 (new OpenFileInputStreamAction(f));
80 if (fis != null) {
81 System.out.println("file test passed");
82 } else {
83 throw new SecurityException("file test failed");
84 }
85 }
86}