CheckCaseInsensitiveEncAliases.java revision 395
0N/A/*
0N/A * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A */
0N/A
0N/A/* @test
0N/A * @bug 4216191 4721369 4807283
0N/A @summary Test to validate case insensitivity of encoding alias names
0N/A */
0N/A
0N/A// Fixed since 1.4.0 by virtue of NIO charset lookup mechanism
0N/A// which is by design case insensitive
0N/A
0N/Aimport java.lang.*;
0N/Aimport java.io.*;
0N/A
0N/Apublic class CheckCaseInsensitiveEncAliases
0N/A{
0N/A public static void main(String args[]) throws Exception
0N/A {
0N/A // Try various encoding names in mixed cases
0N/A // Tests subset of encoding names provided within bugID 4216191
0N/A
0N/A // Various forms of US-ASCII
0N/A tryToEncode( "ANSI_X3.4-1968" );
0N/A tryToEncode( "iso-ir-6" );
0N/A tryToEncode( "ANSI_X3.4-1986" );
0N/A tryToEncode( "ISO_646.irv:1991" );
0N/A tryToEncode( "ASCII" );
0N/A tryToEncode( "ascii" );
0N/A tryToEncode( "Ascii" );
0N/A tryToEncode( "Ascii7" );
0N/A tryToEncode( "ascii7" );
0N/A tryToEncode( "ISO646-US" );
0N/A tryToEncode( "US-ASCII" );
0N/A tryToEncode( "us-ascii" );
0N/A tryToEncode( "US-Ascii" );
0N/A tryToEncode( "us" );
0N/A tryToEncode( "IBM367" );
0N/A tryToEncode( "cp367" );
0N/A tryToEncode( "csASCII" );
0N/A
0N/A // Variants on Unicode
0N/A tryToEncode( "Unicode" );
0N/A tryToEncode( "UNICODE" );
0N/A tryToEncode( "unicode" );
0N/A
0N/A // Variants on Big5
0N/A tryToEncode( "Big5" );
0N/A tryToEncode( "big5" );
0N/A tryToEncode( "bIg5" );
0N/A tryToEncode( "biG5" );
0N/A tryToEncode( "bIG5" );
0N/A
0N/A // Variants of Cp1252
0N/A tryToEncode( "Cp1252" );
0N/A tryToEncode( "cp1252" );
0N/A tryToEncode( "CP1252" );
0N/A
0N/A // Variants of PCK
0N/A tryToEncode( "pck" );
0N/A tryToEncode( "Pck" );
0N/A
0N/A }
0N/A
0N/A
0N/A public static final String ENCODE_STRING = "Encode me";
0N/A
0N/A public static void tryToEncode( String encoding) throws Exception
0N/A {
0N/A try
0N/A {
0N/A byte[] bytes = ENCODE_STRING.getBytes( encoding );
0N/A System.out.println( "Encoding \"" + encoding + "\" recognized" );
0N/A }
0N/A catch( UnsupportedEncodingException e )
0N/A {
0N/A throw new Exception("Encoding \"" + encoding + "\" NOT recognized");
0N/A }
0N/A }
0N/A}
0N/A