1 /*
   2  * Copyright (c) 2007, 2016, 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 4248694
  27  * @modules jdk.localedata
  28  * @summary updating collation tables for icelandic
  29  */
  30 
  31 import java.text.Collator;
  32 import java.util.Arrays;
  33 import java.util.Locale;
  34 
  35 public class Bug4248694 {
  36 
  37   /********************************************************
  38   *********************************************************/
  39   public static void main (String[] args) {
  40       Locale reservedLocale = Locale.getDefault();
  41       try {
  42           int errors=0;
  43 
  44           Locale loc = new Locale ("is", "is");   // Icelandic
  45 
  46           Locale.setDefault (loc);
  47           Collator col = Collator.getInstance ();
  48 
  49           String[] data = {"\u00e6ard",
  50                            "Zard",
  51                            "aard",
  52                            "\u00feard",
  53                            "vird",
  54                            "\u00c6ard",
  55                            "Zerd",
  56                            "\u00deard"};
  57 
  58           String[] sortedData = {"aard",
  59                                  "vird",
  60                                  "Zard",
  61                                  "Zerd",
  62                                  "\u00feard",
  63                                  "\u00deard",
  64                                  "\u00e6ard",
  65                                  "\u00c6ard"};
  66 
  67           Arrays.sort (data, col);
  68 
  69           System.out.println ("Using " + loc.getDisplayName());
  70           for (int i = 0;  i < data.length;  i++) {
  71               System.out.println(data[i] + "  :  " + sortedData[i]);
  72               if (sortedData[i].compareTo(data[i]) != 0) {
  73                   errors++;
  74               }
  75           }//end for
  76 
  77           if (errors > 0)
  78               throw new RuntimeException();
  79       } finally {
  80           // restore the reserved locale
  81           Locale.setDefault(reservedLocale);
  82       }
  83   }//end main
  84 
  85 }//end class CollatorTest