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