summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-04-16 14:14:28 -0700
committerElliott Hughes <enh@google.com>2010-04-16 14:48:27 -0700
commit757a7942eed2b0aa457f8517a0259d2ac82c5b18 (patch)
tree00f74b34ca4edeac65d9cb38d8291ee249f5a806 /luni
parentb988f4652e9325f77c60c5aa4d71a703a0793ec3 (diff)
downloadlibcore-757a7942eed2b0aa457f8517a0259d2ac82c5b18.zip
libcore-757a7942eed2b0aa457f8517a0259d2ac82c5b18.tar.gz
libcore-757a7942eed2b0aa457f8517a0259d2ac82c5b18.tar.bz2
Merge LocaleData and Resources, rename Resources to ICU.
Also move our ICU tests into our little tree of tests. Bug: 2596471 Change-Id: I73b53d74c26ef9bf670f12cac58b51ba61eefead
Diffstat (limited to 'luni')
-rw-r--r--luni/src/main/java/java/util/Calendar.java8
-rw-r--r--luni/src/main/java/java/util/Currency.java21
-rw-r--r--luni/src/main/java/java/util/Formatter.java3
-rw-r--r--luni/src/main/java/java/util/Locale.java164
-rw-r--r--luni/src/main/java/java/util/ResourceBundle.java4
-rw-r--r--luni/src/main/java/java/util/TimeZone.java7
-rw-r--r--luni/src/test/java/com/ibm/icu4jni/util/AllTests.java28
-rw-r--r--luni/src/test/java/com/ibm/icu4jni/util/ICUTest.java74
8 files changed, 189 insertions, 120 deletions
diff --git a/luni/src/main/java/java/util/Calendar.java b/luni/src/main/java/java/util/Calendar.java
index 6cb3ec7..3e5e43d 100644
--- a/luni/src/main/java/java/util/Calendar.java
+++ b/luni/src/main/java/java/util/Calendar.java
@@ -18,7 +18,7 @@
package java.util;
import com.ibm.icu4jni.util.LocaleData;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -724,11 +724,9 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
*/
protected Calendar(TimeZone timezone, Locale locale) {
this(timezone);
- // BEGIN android-changed
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
+ LocaleData localeData = LocaleData.get(locale);
setFirstDayOfWeek(localeData.firstDayOfWeek.intValue());
setMinimalDaysInFirstWeek(localeData.minimalDaysInFirstWeek.intValue());
- // END android-changed
}
@@ -962,7 +960,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
* are available.
*/
public static synchronized Locale[] getAvailableLocales() {
- return Resources.getAvailableCalendarLocales();
+ return ICU.getAvailableCalendarLocales();
}
/**
diff --git a/luni/src/main/java/java/util/Currency.java b/luni/src/main/java/java/util/Currency.java
index a3ab15c..83d7f80 100644
--- a/luni/src/main/java/java/util/Currency.java
+++ b/luni/src/main/java/java/util/Currency.java
@@ -17,16 +17,13 @@
package java.util;
-// BEGIN android-added
+import com.ibm.icu4jni.util.ICU;
import com.ibm.icu4jni.util.LocaleData;
-import com.ibm.icu4jni.util.Resources;
-import java.util.logging.Logger;
-import org.apache.harmony.luni.util.Msg;
-// END android-added
-
-import java.security.AccessController;
import java.io.Serializable;
+import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.logging.Logger;
+import org.apache.harmony.luni.util.Msg;
/**
* This class represents a currency as identified in the ISO 4217 currency
@@ -59,12 +56,12 @@ public final class Currency implements Serializable {
}
// Ensure that we throw if the our currency code isn't an ISO currency code.
- String symbol = Resources.getCurrencySymbolNative(Locale.US.toString(), currencyCode);
+ String symbol = ICU.getCurrencySymbolNative(Locale.US.toString(), currencyCode);
if (symbol == null) {
throw new IllegalArgumentException(Msg.getString("K0322", currencyCode));
}
- this.defaultFractionDigits = Resources.getCurrencyFractionDigitsNative(currencyCode);
+ this.defaultFractionDigits = ICU.getCurrencyFractionDigitsNative(currencyCode);
if (defaultFractionDigits < 0) {
// In practice, I don't think this can fail because ICU doesn't care whether you give
// it a valid country code, and will just return a sensible default for the default
@@ -120,7 +117,7 @@ public final class Currency implements Serializable {
country = country + "_" + variant;
}
- String currencyCode = Resources.getCurrencyCodeNative(country);
+ String currencyCode = ICU.getCurrencyCodeNative(country);
if (currencyCode == null) {
throw new IllegalArgumentException(Msg.getString("K0323", locale.toString()));
} else if (currencyCode.equals("None")) {
@@ -164,13 +161,13 @@ public final class Currency implements Serializable {
}
// Check the locale first, in case the locale has the same currency.
- LocaleData localeData = Resources.getLocaleData(locale);
+ LocaleData localeData = LocaleData.get(locale);
if (localeData.internationalCurrencySymbol.equals(currencyCode)) {
return localeData.currencySymbol;
}
// Try ICU, and fall back to the currency code if ICU has nothing.
- String symbol = Resources.getCurrencySymbolNative(locale.toString(), currencyCode);
+ String symbol = ICU.getCurrencySymbolNative(locale.toString(), currencyCode);
return symbol != null ? symbol : currencyCode;
}
diff --git a/luni/src/main/java/java/util/Formatter.java b/luni/src/main/java/java/util/Formatter.java
index f79fde9..db35ef1 100644
--- a/luni/src/main/java/java/util/Formatter.java
+++ b/luni/src/main/java/java/util/Formatter.java
@@ -16,7 +16,6 @@
package java.util;
import com.ibm.icu4jni.util.LocaleData;
-import com.ibm.icu4jni.util.Resources;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
@@ -1414,7 +1413,7 @@ public final class Formatter implements Closeable, Flushable {
Transformer(Formatter formatter, Locale locale) {
this.formatter = formatter;
this.locale = (locale == null ? Locale.US : locale);
- this.localeData = Resources.getLocaleData(locale);
+ this.localeData = LocaleData.get(locale);
}
private NumberFormat getNumberFormat() {
diff --git a/luni/src/main/java/java/util/Locale.java b/luni/src/main/java/java/util/Locale.java
index 702c5ff..ce1992c 100644
--- a/luni/src/main/java/java/util/Locale.java
+++ b/luni/src/main/java/java/util/Locale.java
@@ -17,7 +17,7 @@
package java.util;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -84,82 +84,82 @@ public final class Locale implements Cloneable, Serializable {
/**
* Locale constant for en_CA.
*/
- public static final Locale CANADA = new Locale("en", "CA"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale CANADA = new Locale("en", "CA");
/**
* Locale constant for fr_CA.
*/
- public static final Locale CANADA_FRENCH = new Locale("fr", "CA"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale CANADA_FRENCH = new Locale("fr", "CA");
/**
* Locale constant for zh_CN.
*/
- public static final Locale CHINA = new Locale("zh", "CN"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale CHINA = new Locale("zh", "CN");
/**
* Locale constant for zh.
*/
- public static final Locale CHINESE = new Locale("zh", ""); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale CHINESE = new Locale("zh", "");
/**
* Locale constant for en.
*/
- public static final Locale ENGLISH = new Locale("en", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale ENGLISH = new Locale("en", "");
/**
* Locale constant for fr_FR.
*/
- public static final Locale FRANCE = new Locale("fr", "FR"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale FRANCE = new Locale("fr", "FR");
/**
* Locale constant for fr.
*/
- public static final Locale FRENCH = new Locale("fr", ""); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale FRENCH = new Locale("fr", "");
/**
* Locale constant for de.
*/
- public static final Locale GERMAN = new Locale("de", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale GERMAN = new Locale("de", "");
/**
* Locale constant for de_DE.
*/
- public static final Locale GERMANY = new Locale("de", "DE"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale GERMANY = new Locale("de", "DE");
/**
* Locale constant for it.
*/
- public static final Locale ITALIAN = new Locale("it", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale ITALIAN = new Locale("it", "");
/**
* Locale constant for it_IT.
*/
- public static final Locale ITALY = new Locale("it", "IT"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale ITALY = new Locale("it", "IT");
/**
* Locale constant for ja_JP.
*/
- public static final Locale JAPAN = new Locale("ja", "JP"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale JAPAN = new Locale("ja", "JP");
/**
* Locale constant for ja.
*/
- public static final Locale JAPANESE = new Locale("ja", ""); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale JAPANESE = new Locale("ja", "");
/**
* Locale constant for ko_KR.
*/
- public static final Locale KOREA = new Locale("ko", "KR"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale KOREA = new Locale("ko", "KR");
/**
* Locale constant for ko.
*/
- public static final Locale KOREAN = new Locale("ko", ""); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale KOREAN = new Locale("ko", "");
/**
* Locale constant for zh_CN.
*/
- public static final Locale PRC = new Locale("zh", "CN"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale PRC = new Locale("zh", "CN");
/**
* Locale constant for the root locale. The root locale has an empty language,
@@ -173,40 +173,35 @@ public final class Locale implements Cloneable, Serializable {
/**
* Locale constant for zh_CN.
*/
- public static final Locale SIMPLIFIED_CHINESE = new Locale("zh", "CN"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale SIMPLIFIED_CHINESE = new Locale("zh", "CN");
/**
* Locale constant for zh_TW.
*/
- public static final Locale TAIWAN = new Locale("zh", "TW"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale TAIWAN = new Locale("zh", "TW");
/**
* Locale constant for zh_TW.
*/
- public static final Locale TRADITIONAL_CHINESE = new Locale("zh", "TW"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale TRADITIONAL_CHINESE = new Locale("zh", "TW");
/**
* Locale constant for en_GB.
*/
- public static final Locale UK = new Locale("en", "GB"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale UK = new Locale("en", "GB");
/**
* Locale constant for en_US.
*/
- public static final Locale US = new Locale("en", "US"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale US = new Locale("en", "US");
private static final PropertyPermission setLocalePermission = new PropertyPermission(
- "user.language", "write"); //$NON-NLS-1$//$NON-NLS-2$
+ "user.language", "write");
static {
- String language = AccessController
- .doPrivileged(new PriviAction<String>("user.language", "en")); //$NON-NLS-1$ //$NON-NLS-2$
- // BEGIN android-changed
- String region = AccessController.doPrivileged(new PriviAction<String>(
- "user.region", "US")); //$NON-NLS-1$ //$NON-NLS-2$
- // END android-changed
- String variant = AccessController.doPrivileged(new PriviAction<String>(
- "user.variant", "")); //$NON-NLS-1$ //$NON-NLS-2$
+ String language = AccessController.doPrivileged(new PriviAction<String>("user.language", "en"));
+ String region = AccessController.doPrivileged(new PriviAction<String>("user.region", "US"));
+ String variant = AccessController.doPrivileged(new PriviAction<String>("user.variant", ""));
defaultLocale = new Locale(language, region, variant);
}
@@ -215,19 +210,15 @@ public final class Locale implements Cloneable, Serializable {
private transient String variantCode;
private transient String cachedToStringResult;
- // BEGIN android-removed
- // private transient ULocale uLocale;
- // END android-removed
-
- /**
- * Constructs a default which is used during static initialization of the
- * default for the platform.
- */
- private Locale() {
- languageCode = "en"; //$NON-NLS-1$
- countryCode = "US"; //$NON-NLS-1$
- variantCode = ""; //$NON-NLS-1$
- }
+ /**
+ * Constructs a default which is used during static initialization of the
+ * default for the platform.
+ */
+ private Locale() {
+ languageCode = "en";
+ countryCode = "US";
+ variantCode = "";
+ }
/**
* Constructs a new {@code Locale} using the specified language.
@@ -236,7 +227,7 @@ public final class Locale implements Cloneable, Serializable {
* the language this {@code Locale} represents.
*/
public Locale(String language) {
- this(language, "", ""); //$NON-NLS-1$//$NON-NLS-2$
+ this(language, "", "");
}
/**
@@ -248,7 +239,7 @@ public final class Locale implements Cloneable, Serializable {
* the country this {@code Locale} represents.
*/
public Locale(String language, String country) {
- this(language, country, ""); //$NON-NLS-1$
+ this(language, country, "");
}
/**
@@ -282,12 +273,12 @@ public final class Locale implements Cloneable, Serializable {
// END android-changed
// Map new language codes to the obsolete language
// codes so the correct resource bundles will be used.
- if (languageCode.equals("he")) {//$NON-NLS-1$
- languageCode = "iw"; //$NON-NLS-1$
- } else if (languageCode.equals("id")) {//$NON-NLS-1$
- languageCode = "in"; //$NON-NLS-1$
- } else if (languageCode.equals("yi")) {//$NON-NLS-1$
- languageCode = "ji"; //$NON-NLS-1$
+ if (languageCode.equals("he")) {
+ languageCode = "iw";
+ } else if (languageCode.equals("id")) {
+ languageCode = "in";
+ } else if (languageCode.equals("yi")) {
+ languageCode = "ji";
}
// countryCode is defined in ASCII character set
@@ -348,7 +339,7 @@ public final class Locale implements Cloneable, Serializable {
* @return an array of {@code Locale}s.
*/
public static Locale[] getAvailableLocales() {
- return Resources.getAvailableLocales();
+ return ICU.getAvailableLocales();
}
/**
@@ -391,16 +382,14 @@ public final class Locale implements Cloneable, Serializable {
* @return a country name.
*/
public String getDisplayCountry(Locale locale) {
- // BEGIN android-changed
if (countryCode.length() == 0) {
return countryCode;
}
- String result = Resources.getDisplayCountryNative(toString(), locale.toString());
+ String result = ICU.getDisplayCountryNative(toString(), locale.toString());
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = Resources.getDisplayCountryNative(toString(), Locale.getDefault().toString());
+ result = ICU.getDisplayCountryNative(toString(), Locale.getDefault().toString());
}
return result;
- // END android-changed
}
/**
@@ -424,16 +413,14 @@ public final class Locale implements Cloneable, Serializable {
* @return a language name.
*/
public String getDisplayLanguage(Locale locale) {
- // BEGIN android-changed
if (languageCode.length() == 0) {
return languageCode;
}
- String result = Resources.getDisplayLanguageNative(toString(), locale.toString());
+ String result = ICU.getDisplayLanguageNative(toString(), locale.toString());
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = Resources.getDisplayLanguageNative(toString(), Locale.getDefault().toString());
+ result = ICU.getDisplayLanguageNative(toString(), Locale.getDefault().toString());
}
return result;
- // END android-changed
}
/**
@@ -463,22 +450,22 @@ public final class Locale implements Cloneable, Serializable {
}
if (countryCode.length() > 0) {
if (count == 1) {
- buffer.append(" ("); //$NON-NLS-1$
+ buffer.append(" (");
}
buffer.append(getDisplayCountry(locale));
count++;
}
if (variantCode.length() > 0) {
if (count == 1) {
- buffer.append(" ("); //$NON-NLS-1$
+ buffer.append(" (");
} else if (count == 2) {
- buffer.append(","); //$NON-NLS-1$
+ buffer.append(",");
}
buffer.append(getDisplayVariant(locale));
count++;
}
if (count > 1) {
- buffer.append(")"); //$NON-NLS-1$
+ buffer.append(")");
}
return buffer.toString();
}
@@ -504,16 +491,14 @@ public final class Locale implements Cloneable, Serializable {
* @return a variant name.
*/
public String getDisplayVariant(Locale locale) {
- // BEGIN android-changed
if (variantCode.length() == 0) {
return variantCode;
}
- String result = Resources.getDisplayVariantNative(toString(), locale.toString());
+ String result = ICU.getDisplayVariantNative(toString(), locale.toString());
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = Resources.getDisplayVariantNative(toString(), Locale.getDefault().toString());
+ result = ICU.getDisplayVariantNative(toString(), Locale.getDefault().toString());
}
return result;
- // END android-changed
}
/**
@@ -525,12 +510,10 @@ public final class Locale implements Cloneable, Serializable {
* if there is no matching three letter ISO country code.
*/
public String getISO3Country() throws MissingResourceException {
- // BEGIN android-changed
if (countryCode.length() == 0) {
return countryCode;
}
- return Resources.getISO3CountryNative(toString());
- // END android-changed
+ return ICU.getISO3CountryNative(toString());
}
/**
@@ -542,12 +525,10 @@ public final class Locale implements Cloneable, Serializable {
* if there is no matching three letter ISO language code.
*/
public String getISO3Language() throws MissingResourceException {
- // BEGIN android-changed
if (languageCode.length() == 0) {
return languageCode;
}
- return Resources.getISO3LanguageNative(toString());
- // END android-changed
+ return ICU.getISO3LanguageNative(toString());
}
/**
@@ -557,9 +538,7 @@ public final class Locale implements Cloneable, Serializable {
* @return an array of strings.
*/
public static String[] getISOCountries() {
- // BEGIN android-changed
- return Resources.getISOCountries();
- // END android-changed
+ return ICU.getISOCountries();
}
/**
@@ -569,9 +548,7 @@ public final class Locale implements Cloneable, Serializable {
* @return an array of strings.
*/
public static String[] getISOLanguages() {
- // BEGIN android-changed
- return Resources.getISOLanguages();
- // END android-changed
+ return ICU.getISOLanguages();
}
/**
@@ -670,25 +647,24 @@ public final class Locale implements Cloneable, Serializable {
}
private static final ObjectStreamField[] serialPersistentFields = {
- new ObjectStreamField("country", String.class), //$NON-NLS-1$
- new ObjectStreamField("hashcode", Integer.TYPE), //$NON-NLS-1$
- new ObjectStreamField("language", String.class), //$NON-NLS-1$
- new ObjectStreamField("variant", String.class) }; //$NON-NLS-1$
+ new ObjectStreamField("country", String.class),
+ new ObjectStreamField("hashcode", Integer.TYPE),
+ new ObjectStreamField("language", String.class),
+ new ObjectStreamField("variant", String.class) };
private void writeObject(ObjectOutputStream stream) throws IOException {
ObjectOutputStream.PutField fields = stream.putFields();
- fields.put("country", countryCode); //$NON-NLS-1$
- fields.put("hashcode", -1); //$NON-NLS-1$
- fields.put("language", languageCode); //$NON-NLS-1$
- fields.put("variant", variantCode); //$NON-NLS-1$
+ fields.put("country", countryCode);
+ fields.put("hashcode", -1);
+ fields.put("language", languageCode);
+ fields.put("variant", variantCode);
stream.writeFields();
}
- private void readObject(ObjectInputStream stream) throws IOException,
- ClassNotFoundException {
+ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = stream.readFields();
- countryCode = (String) fields.get("country", ""); //$NON-NLS-1$//$NON-NLS-2$
- languageCode = (String) fields.get("language", ""); //$NON-NLS-1$//$NON-NLS-2$
- variantCode = (String) fields.get("variant", ""); //$NON-NLS-1$//$NON-NLS-2$
+ countryCode = (String) fields.get("country", "");
+ languageCode = (String) fields.get("language", "");
+ variantCode = (String) fields.get("variant", "");
}
}
diff --git a/luni/src/main/java/java/util/ResourceBundle.java b/luni/src/main/java/java/util/ResourceBundle.java
index 8901e45..dda89b9 100644
--- a/luni/src/main/java/java/util/ResourceBundle.java
+++ b/luni/src/main/java/java/util/ResourceBundle.java
@@ -17,7 +17,7 @@
package java.util;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import dalvik.system.VMStack;
import java.io.File;
import java.io.IOException;
@@ -632,7 +632,7 @@ public abstract class ResourceBundle {
}
private void setLocale(String name) {
- setLocale(Resources.localeFromString(name));
+ setLocale(ICU.localeFromString(name));
}
public static final void clearCache() {
diff --git a/luni/src/main/java/java/util/TimeZone.java b/luni/src/main/java/java/util/TimeZone.java
index dd320b8..a195045 100644
--- a/luni/src/main/java/java/util/TimeZone.java
+++ b/luni/src/main/java/java/util/TimeZone.java
@@ -17,13 +17,10 @@
package java.util;
+import com.ibm.icu4jni.util.ICU;
import java.io.Serializable;
-
-// BEGIN android-added
import org.apache.harmony.luni.internal.util.ZoneInfo;
import org.apache.harmony.luni.internal.util.ZoneInfoDB;
-import com.ibm.icu4jni.util.Resources;
-// END android-added
/**
* {@code TimeZone} represents a time zone offset, taking into account
@@ -276,7 +273,7 @@ public abstract class TimeZone implements Serializable, Cloneable {
if (style == SHORT || style == LONG) {
boolean useDaylight = daylightTime && useDaylightTime();
- String result = Resources.getDisplayTimeZone(getID(), daylightTime, style, locale.toString());
+ String result = ICU.getDisplayTimeZone(getID(), daylightTime, style, locale.toString());
if (result != null) {
return result;
}
diff --git a/luni/src/test/java/com/ibm/icu4jni/util/AllTests.java b/luni/src/test/java/com/ibm/icu4jni/util/AllTests.java
new file mode 100644
index 0000000..2db1dcc
--- /dev/null
+++ b/luni/src/test/java/com/ibm/icu4jni/util/AllTests.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ibm.icu4jni.util;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+ public static final Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(ICUTest.class);
+ return suite;
+ }
+}
diff --git a/luni/src/test/java/com/ibm/icu4jni/util/ICUTest.java b/luni/src/test/java/com/ibm/icu4jni/util/ICUTest.java
new file mode 100644
index 0000000..f8797b3
--- /dev/null
+++ b/luni/src/test/java/com/ibm/icu4jni/util/ICUTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ibm.icu4jni.util;
+
+import java.util.Locale;
+
+public class ICUTest extends junit.framework.TestCase {
+ public void test_getISOLanguages() throws Exception {
+ // Check that corrupting our array doesn't affect other callers.
+ assertNotNull(ICU.getISOLanguages()[0]);
+ ICU.getISOLanguages()[0] = null;
+ assertNotNull(ICU.getISOLanguages()[0]);
+ }
+
+ public void test_getISOCountries() throws Exception {
+ // Check that corrupting our array doesn't affect other callers.
+ assertNotNull(ICU.getISOCountries()[0]);
+ ICU.getISOCountries()[0] = null;
+ assertNotNull(ICU.getISOCountries()[0]);
+ }
+
+ public void test_getAvailableLocales() throws Exception {
+ // Check that corrupting our array doesn't affect other callers.
+ assertNotNull(ICU.getAvailableLocales()[0]);
+ ICU.getAvailableLocales()[0] = null;
+ assertNotNull(ICU.getAvailableLocales()[0]);
+ }
+
+ public void test_getKnownTimezones() throws Exception {
+ // Check that corrupting our array doesn't affect other callers.
+ assertNotNull(ICU.getKnownTimezones()[0]);
+ ICU.getKnownTimezones()[0] = null;
+ assertNotNull(ICU.getKnownTimezones()[0]);
+ }
+
+ public void test_getDisplayTimeZones() throws Exception {
+ // Check that corrupting our array doesn't affect other callers.
+ assertNotNull(ICU.getDisplayTimeZones(null)[0]);
+ ICU.getDisplayTimeZones(null)[0] = null;
+ assertNotNull(ICU.getDisplayTimeZones(null)[0]);
+ // getDisplayTimezones actually returns a String[][] rather than a String[].
+ assertNotNull(ICU.getDisplayTimeZones(null)[0][0]);
+ ICU.getDisplayTimeZones(null)[0][0] = null;
+ assertNotNull(ICU.getDisplayTimeZones(null)[0][0]);
+ }
+
+ public void test_localeFromString() throws Exception {
+ // localeFromString is pretty lenient. Some of these can't be round-tripped
+ // through Locale.toString.
+ assertEquals(Locale.ENGLISH, ICU.localeFromString("en"));
+ assertEquals(Locale.ENGLISH, ICU.localeFromString("en_"));
+ assertEquals(Locale.ENGLISH, ICU.localeFromString("en__"));
+ assertEquals(Locale.US, ICU.localeFromString("en_US"));
+ assertEquals(Locale.US, ICU.localeFromString("en_US_"));
+ assertEquals(new Locale("", "US", ""), ICU.localeFromString("_US"));
+ assertEquals(new Locale("", "US", ""), ICU.localeFromString("_US_"));
+ assertEquals(new Locale("", "", "POSIX"), ICU.localeFromString("__POSIX"));
+ assertEquals(new Locale("aa", "BB", "CC"), ICU.localeFromString("aa_BB_CC"));
+ }
+}