Path: blob/master/test/jdk/java/lang/System/MacEncoding/MacJNUEncoding.java
41153 views
/*1* Copyright (c) 2017, 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 800322826* @summary Test the value of sun.jnu.encoding on Mac27* @requires (os.family == "mac")28* @library /test/lib29* @build jdk.test.lib.process.*30* ExpectedEncoding31* @run main MacJNUEncoding US-ASCII UTF-8 C32* @run main MacJNUEncoding UTF-8 UTF-8 en_US.UTF-833*/3435import java.util.Map;3637import jdk.test.lib.process.ProcessTools;3839public class MacJNUEncoding {4041public static void main(String[] args) throws Exception {42if (args.length != 3) {43System.out.println("Usage:");44System.out.println(" java MacJNUEncoding"45+ " <expected file.encoding> <expected sun.jnu.encoding> <locale>");46throw new IllegalArgumentException("missing arguments");47}4849final String locale = args[2];50System.out.println("Running test for locale: " + locale);51ProcessBuilder pb = ProcessTools.createTestJvm(52ExpectedEncoding.class.getName(), args[0], args[1]);53Map<String, String> env = pb.environment();54env.put("LANG", locale);55env.put("LC_ALL", locale);56ProcessTools.executeProcess(pb)57.outputTo(System.out)58.errorTo(System.err)59.shouldHaveExitValue(0);60}61}626364