1 /* 2 * Copyright (c) 2007, 2011, 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 /* 25 * @test 26 * @bug 4804273 27 * @summary updating collation tables for swedish 28 */ 29 30 import java.text.*; 31 import java.util.*; 32 33 public class Bug4804273 { 34 35 /******************************************************** 36 *********************************************************/ 37 public static void main (String[] args) { 38 Locale reservedLocale = Locale.getDefault(); 39 try { 40 int errors=0; 41 42 Locale loc = new Locale ("sv", "se"); // Swedish 43 44 Locale.setDefault (loc); 45 Collator col = Collator.getInstance (); 46 47 String[] data = {"A", 48 "Aa", 49 "Ae", 50 "B", 51 "Y", 52 "U\u0308", // U-umlaut 53 "Z", 54 "A\u030a", // A-ring 55 "A\u0308", // A-umlaut 56 "\u00c6", // AE ligature 57 "O\u0308", // O-umlaut 58 "a\u030b", // a-double-acute 59 "\u00d8", // O-stroke 60 "a", 61 "aa", 62 "ae", 63 "b", 64 "y", 65 "u\u0308", // u-umlaut 66 "z", 67 "A\u030b", // A-double-acute 68 "a\u030a", // a-ring 69 "a\u0308", // a-umlaut 70 "\u00e6", // ae ligature 71 "o\u0308", // o-umlaut 72 "\u00f8", // o-stroke 73 }; 74 75 76 String[] sortedData = {"a", 77 "A", 78 "aa", 79 "Aa", 80 "ae", 81 "Ae", 82 "b", 83 "B", 84 "y", 85 "Y", 86 "u\u0308", // o-umlaut 87 "U\u0308", // o-umlaut 88 "z", 89 "Z", 90 "a\u030a", // a-ring 91 "A\u030a", // A-ring 92 "a\u0308", // a-umlaut 93 "A\u0308", // A-umlaut 94 "a\u030b", // a-double-acute 95 "A\u030b", // A-double-acute 96 "\u00e6", // ae ligature 97 "\u00c6", // AE ligature 98 "o\u0308", // o-umlaut 99 "O\u0308", // O-umlaut 100 "\u00f8", // o-stroke 101 "\u00d8", // O-stroke 102 }; 103 104 Arrays.sort (data, col); 105 106 System.out.println ("Using " + loc.getDisplayName()); 107 for (int i = 0; i < data.length; i++) { 108 System.out.println(data[i] + " : " + sortedData[i]); 109 if (sortedData[i].compareTo(data[i]) != 0) { 110 errors++; 111 } 112 }//end for 113 114 if (errors > 0) 115 throw new RuntimeException("There are " + errors + 116 " words sorted incorrectly!"); 117 } finally { 118 // restore the reserved locale 119 Locale.setDefault(reservedLocale); 120 } 121 }//end main 122 123 }//end class CollatorTest