2 *******************************************************************************
3 * Copyright (C) 2009, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
8 package com.ibm.icu.dev.test.util;
10 import java.util.HashMap;
12 import com.ibm.icu.text.Collator;
13 import com.ibm.icu.util.ULocale;
15 public class LocaleAliasCollationTest extends com.ibm.icu.dev.test.TestFmwk {
16 private static final ULocale[][] _LOCALES = {
17 {new ULocale("en", "RH"), new ULocale("en", "ZW")},
18 {new ULocale("in"), new ULocale("id")},
19 {new ULocale("in", "ID"), new ULocale("id", "ID")},
20 {new ULocale("iw"), new ULocale("he")},
21 {new ULocale("iw", "IL"), new ULocale("he", "IL")},
22 {new ULocale("ji"), new ULocale("yi")},
24 {new ULocale("en", "BU"), new ULocale("en", "MM")},
25 {new ULocale("en", "DY"), new ULocale("en", "BJ")},
26 {new ULocale("en", "HV"), new ULocale("en", "BF")},
27 {new ULocale("en", "NH"), new ULocale("en", "VU")},
28 {new ULocale("en", "TP"), new ULocale("en", "TL")},
29 {new ULocale("en", "ZR"), new ULocale("en", "CD")}
32 private static final int _LOCALE_NUMBER = _LOCALES.length;
33 private static ULocale[] available = null;
34 private HashMap availableMap = new HashMap();
35 private static final ULocale _DEFAULT_LOCALE = ULocale.US;
37 public static void main(String[] args) {
38 new LocaleAliasCollationTest().run(args);
41 public LocaleAliasCollationTest() {
44 protected void init(){
45 available = ULocale.getAvailableLocales();
46 for(int i=0; i<available.length;i++){
47 availableMap.put(available[i].toString(),"");
51 public void TestCollation() {
52 ULocale defLoc = ULocale.getDefault();
53 ULocale.setDefault(_DEFAULT_LOCALE);
54 for (int i=0; i<_LOCALE_NUMBER; i++) {
55 ULocale oldLoc = _LOCALES[i][0];
56 ULocale newLoc = _LOCALES[i][1];
57 if(availableMap.get(_LOCALES[i][1])==null){
58 logln(_LOCALES[i][1]+" is not available. Skipping!");
61 Collator c1 = Collator.getInstance(oldLoc);
62 Collator c2 = Collator.getInstance(newLoc);
65 errln("CollationTest: c1!=c2: newLoc= "+newLoc +" oldLoc= "+oldLoc);
68 logln("Collation old:"+oldLoc+" new:"+newLoc);
70 ULocale.setDefault(defLoc);