Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/nio/charset/coders/SJISPropTest.java
38828 views
/*1* Copyright (c) 2010, 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*25*26* Regression test class run by CheckSJISMappingProp.sh to verify27* that sun.nio.cs.map property is correctly interpreted in28* multibyte Japanese locales29*30*/3132public class SJISPropTest {33public static void main(String[] args) throws Exception {34boolean sjisIsMS932 = false;3536if (args[0].equals("MS932"))37sjisIsMS932 = true;38byte[] testBytes = { (byte)0x81, (byte)0x60 };3940// JIS X based Shift_JIS and Windows-31J differ41// in a number of mappings including this one.4243String expectedMS932 = new String("\uFF5E");44String expectedSJIS = new String("\u301C");4546// Alias "shift_jis" will map to Windows-31J47// if the sun.nio.cs.map system property is defined as48// "Windows-31J/Shift_JIS". This should work in all49// multibyte (especially Japanese) locales.5051String s = new String(testBytes, "shift_jis");5253if (sjisIsMS932 && !s.equals(expectedMS932))54throw new Exception("not MS932");55else if (!sjisIsMS932 && !s.equals(expectedSJIS))56throw new Exception("not SJIS");57}58}596061