Path: blob/master/test/jdk/java/lang/System/NonAnsiFileEncodingTest.java
41149 views
/*1* Copyright (c) 2018, 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 445909926* @key i18n27* @summary Tests non ANSI code page locales set default file encoding28* to "utf-8". This test must be run on Windows 2K/XP in one of Armenian,29* Georgian, Hindi, Punjabi, Gujarati, Tamil, Telugu, Kannada, Marathi,30* or Sanskrit languages.31*/3233public class NonAnsiFileEncodingTest {34public static void main(String[] s) {35String OS = System.getProperty("os.name");36String lang = System.getProperty("user.language");37String fileenc = System.getProperty("file.encoding");3839if (!(OS.equals("Windows 2000") || OS.equals("Windows XP"))) {40System.out.println("This test is not meaningful on the platform \"" + OS + "\".");41return;42}4344if (!(lang.equals("hy") || // Armenian45lang.equals("ka") || // Georgian46lang.equals("hi") || // Hindi47lang.equals("pa") || // Punjabi48lang.equals("gu") || // Gujarati49lang.equals("ta") || // Tamil50lang.equals("te") || // Telugu51lang.equals("kn") || // Kannada52lang.equals("mr") || // Marathi53lang.equals("sa"))) { // Sanskrit54System.out.println("Windows' locale settings for this test is incorrect. Select one of \"Armenian\", \"Georgian\", \"Hindi\", \"Punjabi\", \"Gujarati\", \"Tamil\", \"Telugu\", \"Kannada\", \"Marathi\", or \"Sanskrit\" for the user locale, and \"English(United States)\" for the system default locale using the Control Panel.");55return;56}5758if (!fileenc.equals("utf-8")) {59throw new RuntimeException("file.encoding is incorrectly set to \"" + fileenc + "\". Should be \"utf-8\".");60}61}62}636465