Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/action/Generify.java
38838 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*/2829import java.io.*;30import java.security.*;31import sun.security.action.*;3233public class Generify {3435public static void main(String[] args) throws Exception {3637long larg = 1234567890L;3839System.setProperty("boolean", "true");40System.setProperty("integer", "9");41System.setProperty("long", Long.toString(larg));42System.setProperty("property", "propertyvalue");4344Boolean b = AccessController.doPrivileged45(new GetBooleanAction("boolean"));46if (b.booleanValue() == true) {47System.out.println("boolean test passed");48} else {49throw new SecurityException("boolean test failed");50}5152Integer i = AccessController.doPrivileged53(new GetIntegerAction("integer"));54if (i.intValue() == 9) {55System.out.println("integer test passed");56} else {57throw new SecurityException("integer test failed");58}5960Long l = AccessController.doPrivileged61(new GetLongAction("long"));62if (l.longValue() == larg) {63System.out.println("long test passed");64} else {65throw new SecurityException("long test failed");66}6768String prop = AccessController.doPrivileged69(new GetPropertyAction("property"));70if (prop.equals("propertyvalue")) {71System.out.println("property test passed");72} else {73throw new SecurityException("property test failed");74}7576File f = new File(System.getProperty("test.src", "."), "Generify.java");77FileInputStream fis = AccessController.doPrivileged78(new OpenFileInputStreamAction(f));79if (fis != null) {80System.out.println("file test passed");81} else {82throw new SecurityException("file test failed");83}84}85}868788