1 /* 2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* @test 25 * @bug 4626545 4696726 26 * @summary Checks the inter containment relationships between NIO charsets 27 * @modules jdk.charsets 28 */ 29 30 import java.nio.charset.*; 31 32 public class CharsetContainmentTest { 33 static String[] encodings = 34 { "US-ASCII", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-8", 35 "windows-1252", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", 36 "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", 37 "ISO-8859-8", "ISO-8859-9", "ISO-8859-13", "ISO-8859-15", "ISO-8859-16", 38 "ISO-2022-JP", "ISO-2022-KR", 39 40 // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder 41 // support is added (4673614) 42 // "x-ISO-2022-CN-CNS", "x-ISO-2022-CN-GB", 43 44 "x-ISCII91", "GBK", "GB18030", "Big5", 45 "x-EUC-TW", "GB2312", "EUC-KR", "x-Johab", "Big5-HKSCS", 46 "x-MS950-HKSCS", "windows-1251", "windows-1253", "windows-1254", 47 "windows-1255", "windows-1256", "windows-1257", "windows-1258", 48 "x-mswin-936", "x-windows-949", "x-windows-950", "windows-31j", 49 "Shift_JIS", "EUC-JP", "KOI8-R", "TIS-620" 50 }; 51 52 static String[][] contains = { 53 { "US-ASCII"}, 54 encodings, 55 encodings, 56 encodings, 57 encodings, 58 {"US-ASCII", "windows-1252"}, 59 {"US-ASCII", "ISO-8859-1"}, 60 {"US-ASCII", "ISO-8859-2"}, 61 {"US-ASCII", "ISO-8859-3"}, 62 {"US-ASCII", "ISO-8859-4"}, 63 {"US-ASCII", "ISO-8859-5"}, 64 {"US-ASCII", "ISO-8859-6"}, 65 {"US-ASCII", "ISO-8859-7"}, 66 {"US-ASCII", "ISO-8859-8"}, 67 {"US-ASCII", "ISO-8859-9"}, 68 {"US-ASCII", "ISO-8859-13"}, 69 {"US-ASCII", "ISO-8859-15"}, 70 {"US-ASCII", "ISO-8859-16"}, 71 {"ISO-2022-JP"}, 72 {"ISO-2022-KR"}, 73 // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder 74 // support is added (4673614) 75 //{"x-ISO-2022-CN-CNS"}, 76 //{"x-ISO-2022-CN-GB"}, 77 {"US-ASCII", "x-ISCII91"}, 78 {"US-ASCII", "GBK"}, 79 encodings, 80 {"US-ASCII", "Big5"}, 81 {"US-ASCII", "x-EUC-TW"}, 82 {"US-ASCII", "GB2312"}, 83 {"US-ASCII", "EUC-KR"}, 84 {"US-ASCII", "x-Johab"}, 85 {"US-ASCII", "Big5-HKSCS", "Big5"}, 86 {"US-ASCII", "x-MS950-HKSCS", "x-windows-950"}, 87 {"US-ASCII", "windows-1251"}, 88 {"US-ASCII", "windows-1253"}, 89 {"US-ASCII", "windows-1254"}, 90 {"US-ASCII", "windows-1255"}, 91 {"US-ASCII", "windows-1256"}, 92 {"US-ASCII", "windows-1257"}, 93 {"US-ASCII", "windows-1258"}, 94 {"US-ASCII", "x-mswin-936"}, 95 {"US-ASCII", "x-windows-949"}, 96 {"US-ASCII", "x-windows-950"}, 97 {"US-ASCII", "windows-31j" }, 98 {"US-ASCII", "Shift_JIS"}, 99 {"US-ASCII", "EUC-JP"}, 100 {"US-ASCII", "KOI8-R"}, 101 {"US-ASCII", "TIS-620"}}; 102 103 main(String[] args)104 public static void main(String[] args) throws Exception { 105 for (int i = 0; i < encodings.length; i++) { 106 Charset c = Charset.forName(encodings[i]); 107 for (int j = 0 ; j < contains[i].length; j++) { 108 if (c.contains(Charset.forName(contains[i][j]))) 109 continue; 110 else { 111 throw new Exception ("Error: charset " + encodings[i] + 112 "doesn't contain " + contains[i][j]); 113 } 114 } 115 } 116 } 117 } 118