--- a/jdk/test/java/util/Locale/LocaleEnhanceTest.java Wed Apr 13 21:08:08 2011 +0400
+++ b/jdk/test/java/util/Locale/LocaleEnhanceTest.java Thu Apr 14 15:59:47 2011 +0900
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, 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
@@ -33,8 +33,10 @@
import java.io.ObjectOutputStream;
import java.net.URISyntaxException;
import java.net.URL;
+import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Calendar;
import java.util.IllformedLocaleException;
import java.util.List;
import java.util.Locale;
@@ -43,8 +45,10 @@
/**
* @test
- * @bug 6875847 6992272 7002320 7015500 7023613
+ * @bug 6875847 6992272 7002320 7015500 7023613 7032820 7033504
* @summary test API changes to Locale
+ * @compile LocaleEnhanceTest.java
+ * @run main/othervm -esa LocaleEnhanceTest
*/
public class LocaleEnhanceTest extends LocaleTestFmwk {
@@ -593,6 +597,9 @@
assertEquals("extension", "aa-00-bb-01", locale.getExtension('d'));
assertEquals("extension c", "1234", locale.getExtension('c'));
+ locale = Locale.forLanguageTag("und-U-ca-gregory-u-ca-japanese");
+ assertEquals("Unicode extension", "ca-gregory", locale.getExtension(Locale.UNICODE_LOCALE_EXTENSION));
+
// redundant Unicode locale keys in an extension are ignored
locale = Locale.forLanguageTag("und-u-aa-000-bb-001-bB-002-cc-003-c-1234");
assertEquals("Unicode keywords", "aa-000-bb-001-cc-003", locale.getExtension(Locale.UNICODE_LOCALE_EXTENSION));
@@ -1275,6 +1282,35 @@
}
}
+ /*
+ * 7033504: (lc) incompatible behavior change for ja_JP_JP and th_TH_TH locales
+ */
+ public void testBug7033504() {
+ checkCalendar(new Locale("ja", "JP", "jp"), "java.util.GregorianCalendar");
+ checkCalendar(new Locale("ja", "jp", "jp"), "java.util.GregorianCalendar");
+ checkCalendar(new Locale("ja", "JP", "JP"), "java.util.JapaneseImperialCalendar");
+ checkCalendar(new Locale("ja", "jp", "JP"), "java.util.JapaneseImperialCalendar");
+ checkCalendar(Locale.forLanguageTag("en-u-ca-japanese"),
+ "java.util.JapaneseImperialCalendar");
+
+ checkDigit(new Locale("th", "TH", "th"), '0');
+ checkDigit(new Locale("th", "th", "th"), '0');
+ checkDigit(new Locale("th", "TH", "TH"), '\u0e50');
+ checkDigit(new Locale("th", "TH", "TH"), '\u0e50');
+ checkDigit(Locale.forLanguageTag("en-u-nu-thai"), '\u0e50');
+ }
+
+ private void checkCalendar(Locale loc, String expected) {
+ Calendar cal = Calendar.getInstance(loc);
+ assertEquals("Wrong calendar", expected, cal.getClass().getName());
+ }
+
+ private void checkDigit(Locale loc, Character expected) {
+ DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(loc);
+ Character zero = dfs.getZeroDigit();
+ assertEquals("Wrong digit zero char", expected, zero);
+ }
+
///
/// utility asserts
///