Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/nio/charset/Charset/CharsetContainmentTest.java
38821 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/* @test24@bug 4626545 469672625@summary Checks the inter containment relationships between NIO charsets26*/2728import java.nio.charset.*;2930public class CharsetContainmentTest {31static String[] encodings =32{ "US-ASCII", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-8",33"windows-1252", "ISO-8859-1", "ISO-8859-15", "ISO-8859-2",34"ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6",35"ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-13",36"ISO-2022-JP", "ISO-2022-KR",3738// Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder39// support is added (4673614)40// "x-ISO-2022-CN-CNS", "x-ISO-2022-CN-GB",4142"x-ISCII91", "GBK", "GB18030", "Big5",43"x-EUC-TW", "GB2312", "EUC-KR", "x-Johab", "Big5-HKSCS",44"x-MS950-HKSCS", "windows-1251", "windows-1253", "windows-1254",45"windows-1255", "windows-1256", "windows-1257", "windows-1258",46"x-mswin-936", "x-windows-949", "x-windows-950", "windows-31j",47"Shift_JIS", "EUC-JP", "KOI8-R", "TIS-620"48};4950static String[][] contains = {51{ "US-ASCII"},52encodings,53encodings,54encodings,55encodings,56{"US-ASCII", "windows-1252"},57{"US-ASCII", "ISO-8859-1"},58{"US-ASCII", "ISO-8859-15"},59{"US-ASCII", "ISO-8859-2"},60{"US-ASCII", "ISO-8859-3"},61{"US-ASCII", "ISO-8859-4"},62{"US-ASCII", "ISO-8859-5"},63{"US-ASCII", "ISO-8859-6"},64{"US-ASCII", "ISO-8859-7"},65{"US-ASCII", "ISO-8859-8"},66{"US-ASCII", "ISO-8859-9"},67{"US-ASCII", "ISO-8859-13"},68{"ISO-2022-JP"},69{"ISO-2022-KR"},70// Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder71// support is added (4673614)72//{"x-ISO-2022-CN-CNS"},73//{"x-ISO-2022-CN-GB"},74{"US-ASCII", "x-ISCII91"},75{"US-ASCII", "GBK"},76encodings,77{"US-ASCII", "Big5"},78{"US-ASCII", "x-EUC-TW"},79{"US-ASCII", "GB2312"},80{"US-ASCII", "EUC-KR"},81{"US-ASCII", "x-Johab"},82{"US-ASCII", "Big5-HKSCS", "Big5"},83{"US-ASCII", "x-MS950-HKSCS", "x-windows-950"},84{"US-ASCII", "windows-1251"},85{"US-ASCII", "windows-1253"},86{"US-ASCII", "windows-1254"},87{"US-ASCII", "windows-1255"},88{"US-ASCII", "windows-1256"},89{"US-ASCII", "windows-1257"},90{"US-ASCII", "windows-1258"},91{"US-ASCII", "x-mswin-936"},92{"US-ASCII", "x-windows-949"},93{"US-ASCII", "x-windows-950"},94{"US-ASCII", "windows-31j" },95{"US-ASCII", "Shift_JIS"},96{"US-ASCII", "EUC-JP"},97{"US-ASCII", "KOI8-R"},98{"US-ASCII", "TIS-620"}};99100101public static void main(String[] args) throws Exception {102for (int i = 0; i < encodings.length; i++) {103Charset c = Charset.forName(encodings[i]);104for (int j = 0 ; j < contains[i].length; j++) {105if (c.contains(Charset.forName(contains[i][j])))106continue;107else {108throw new Exception ("Error: charset " + encodings[i] +109"doesn't contain " + contains[i][j]);110}111}112}113}114}115116117