< prev index next >

test/jdk/sun/nio/cs/CheckHistoricalNames.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 20,35 **** * or visit www.oracle.com if you need additional information or have any * questions. */ /* @test ! * @bug 4513767 4961027 6217210 * @summary Checks canonical names match between old and (NIO) core charsets * @modules jdk.charsets */ import java.io.InputStreamReader; import java.io.IOException; public class CheckHistoricalNames { static int failed = 0; public static void main (String[] args) throws Exception { checkHistoricalName("ASCII"); --- 20,37 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ /* @test ! * @bug 4513767 4961027 6217210 8242541 * @summary Checks canonical names match between old and (NIO) core charsets * @modules jdk.charsets */ import java.io.InputStreamReader; import java.io.IOException; + import java.nio.charset.Charset; + import java.nio.charset.UnsupportedCharsetException; public class CheckHistoricalNames { static int failed = 0; public static void main (String[] args) throws Exception { checkHistoricalName("ASCII");
*** 292,301 **** --- 294,304 ---- checkMappedName("x-MacRomania", "MacRomania"); checkMappedName("x-MacSymbol", "MacSymbol"); checkMappedName("x-MacThai", "MacThai"); checkMappedName("x-MacTurkish", "MacTurkish"); checkMappedName("x-MacUkraine", "MacUkraine"); + checkCharsetAndHistoricalName(); if (failed != 0) throw new Exception("Test Failed: " + failed); else System.out.println("Test Passed!");
*** 313,318 **** --- 316,341 ---- + " - expected " + canonical + ", got " + reader.getEncoding()); failed++; } } + + private static void checkCharsetAndHistoricalName() { + for (Charset cs : Charset.availableCharsets().values()) { + InputStreamReader isr = new InputStreamReader(System.in, cs); + String encoding = isr.getEncoding(); + try { + Charset csHist = Charset.forName(encoding); + if (!cs.equals(csHist)) { + System.out.println("Failed charset name" + + " - expected " + cs.name() + + ", got " + csHist.name()); + failed++; + } + } catch (UnsupportedCharsetException uce) { + System.out.println("Failed : charset - "+ cs.name() + + ", missing alias entry - " + encoding); + failed++; + } + } + } }
< prev index next >