Path: blob/master/test/jdk/java/nio/charset/Charset/CharsetContainmentTest.java
41155 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* @modules jdk.charsets27*/2829import java.nio.charset.*;3031public class CharsetContainmentTest {32static String[] encodings =33{ "US-ASCII", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-8",34"windows-1252", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3",35"ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7",36"ISO-8859-8", "ISO-8859-9", "ISO-8859-13", "ISO-8859-15", "ISO-8859-16",37"ISO-2022-JP", "ISO-2022-KR",3839// Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder40// support is added (4673614)41// "x-ISO-2022-CN-CNS", "x-ISO-2022-CN-GB",4243"x-ISCII91", "GBK", "GB18030", "Big5",44"x-EUC-TW", "GB2312", "EUC-KR", "x-Johab", "Big5-HKSCS",45"x-MS950-HKSCS", "windows-1251", "windows-1253", "windows-1254",46"windows-1255", "windows-1256", "windows-1257", "windows-1258",47"x-mswin-936", "x-windows-949", "x-windows-950", "windows-31j",48"Shift_JIS", "EUC-JP", "KOI8-R", "TIS-620"49};5051static String[][] contains = {52{ "US-ASCII"},53encodings,54encodings,55encodings,56encodings,57{"US-ASCII", "windows-1252"},58{"US-ASCII", "ISO-8859-1"},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{"US-ASCII", "ISO-8859-15"},69{"US-ASCII", "ISO-8859-16"},70{"ISO-2022-JP"},71{"ISO-2022-KR"},72// Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder73// support is added (4673614)74//{"x-ISO-2022-CN-CNS"},75//{"x-ISO-2022-CN-GB"},76{"US-ASCII", "x-ISCII91"},77{"US-ASCII", "GBK"},78encodings,79{"US-ASCII", "Big5"},80{"US-ASCII", "x-EUC-TW"},81{"US-ASCII", "GB2312"},82{"US-ASCII", "EUC-KR"},83{"US-ASCII", "x-Johab"},84{"US-ASCII", "Big5-HKSCS", "Big5"},85{"US-ASCII", "x-MS950-HKSCS", "x-windows-950"},86{"US-ASCII", "windows-1251"},87{"US-ASCII", "windows-1253"},88{"US-ASCII", "windows-1254"},89{"US-ASCII", "windows-1255"},90{"US-ASCII", "windows-1256"},91{"US-ASCII", "windows-1257"},92{"US-ASCII", "windows-1258"},93{"US-ASCII", "x-mswin-936"},94{"US-ASCII", "x-windows-949"},95{"US-ASCII", "x-windows-950"},96{"US-ASCII", "windows-31j" },97{"US-ASCII", "Shift_JIS"},98{"US-ASCII", "EUC-JP"},99{"US-ASCII", "KOI8-R"},100{"US-ASCII", "TIS-620"}};101102103public static void main(String[] args) throws Exception {104for (int i = 0; i < encodings.length; i++) {105Charset c = Charset.forName(encodings[i]);106for (int j = 0 ; j < contains[i].length; j++) {107if (c.contains(Charset.forName(contains[i][j])))108continue;109else {110throw new Exception ("Error: charset " + encodings[i] +111"doesn't contain " + contains[i][j]);112}113}114}115}116}117118119