Path: blob/master/test/jdk/sun/security/action/Generify.java
41152 views
/*1* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 505713626* @summary Generify sun.security.action.GetPropertyAction and friends27* @modules java.base/sun.security.action28*/2930import java.io.*;31import java.security.*;32import sun.security.action.*;3334public class Generify {3536public static void main(String[] args) throws Exception {3738long larg = 1234567890L;3940System.setProperty("boolean", "true");41System.setProperty("integer", "9");42System.setProperty("long", Long.toString(larg));43System.setProperty("property", "propertyvalue");4445Boolean b = AccessController.doPrivileged46(new GetBooleanAction("boolean"));47if (b.booleanValue() == true) {48System.out.println("boolean test passed");49} else {50throw new SecurityException("boolean test failed");51}5253Integer i = AccessController.doPrivileged54(new GetIntegerAction("integer"));55if (i.intValue() == 9) {56System.out.println("integer test passed");57} else {58throw new SecurityException("integer test failed");59}6061Long l = AccessController.doPrivileged62(new GetLongAction("long"));63if (l.longValue() == larg) {64System.out.println("long test passed");65} else {66throw new SecurityException("long test failed");67}6869String prop = AccessController.doPrivileged70(new GetPropertyAction("property"));71if (prop.equals("propertyvalue")) {72System.out.println("property test passed");73} else {74throw new SecurityException("property test failed");75}7677File f = new File(System.getProperty("test.src", "."), "Generify.java");78FileInputStream fis = AccessController.doPrivileged79(new OpenFileInputStreamAction(f));80if (fis != null) {81System.out.println("file test passed");82} else {83throw new SecurityException("file test failed");84}85}86}878889