mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-5976 Updated build files and project files. Added TestGetInstance for all service provider classes. Some bug fixes.
X-SVN-Rev: 24104
This commit is contained in:
parent
fb3c554196
commit
fc6eab0cd7
18 changed files with 591 additions and 23 deletions
4
.gitattributes
vendored
4
.gitattributes
vendored
|
@ -84,7 +84,9 @@ icu4j/eclipseProjectMisc/initSrc.launch -text
|
|||
icu4j/eclipseProjectMisc/normSrc.launch -text
|
||||
icu4j/ee.foundation.jar -text
|
||||
icu4j/localespi/.classpath -text
|
||||
icu4j/localespi/.externalToolBuilders/localespi_jar.launch -text
|
||||
icu4j/localespi/.project -text
|
||||
icu4j/localespi/.settings/org.eclipse.core.resources.prefs -text
|
||||
icu4j/localespi/.settings/org.eclipse.jdt.core.prefs -text
|
||||
icu4j/localespi/.settings/org.eclipse.jdt.ui.prefs -text
|
||||
icu4j/localespi/src/META-INF/services/java.text.spi.BreakIteratorProvider -text
|
||||
|
@ -95,7 +97,7 @@ icu4j/localespi/src/META-INF/services/java.text.spi.DecimalFormatSymbolsProvider
|
|||
icu4j/localespi/src/META-INF/services/java.text.spi.NumberFormatProvider -text
|
||||
icu4j/localespi/src/META-INF/services/java.util.spi.CurrencyNameProvider -text
|
||||
icu4j/localespi/src/META-INF/services/java.util.spi.LocaleNameProvider -text
|
||||
icu4j/localespi/src/META-INF/services/java.util.spi.TimeZoneNameProviderICU -text
|
||||
icu4j/localespi/src/META-INF/services/java.util.spi.TimeZoneNameProvider -text
|
||||
icu4j/localespi/src/com/ibm/icu/impl/javaspi/ICUProvider.properties -text
|
||||
icu4j/preprocessor.txt -text
|
||||
icu4j/src/com/ibm/icu/ICUConfig.properties -text
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Java6"/>
|
||||
<classpathentry excluding="**/.svn/**" kind="src" path="src"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/icu4j"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK6"/>
|
||||
<classpathentry kind="output" path="classes"/>
|
||||
</classpath>
|
||||
|
|
23
icu4j/localespi/.externalToolBuilders/localespi_jar.launch
Normal file
23
icu4j/localespi/.externalToolBuilders/localespi_jar.launch
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="jar,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="jar,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="jar,"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/icu4j/localespi/build.xml"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="icu4j-localespi"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/icu4j-localespi/build.xml}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/icu4j-localespi}"/>
|
||||
</launchConfiguration>
|
|
@ -10,6 +10,16 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/localespi_jar.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#Tue Jun 03 11:37:05 EDT 2008
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=US-ASCII
|
|
@ -1,5 +1,13 @@
|
|||
#Mon May 19 23:22:16 EDT 2008
|
||||
#Tue May 20 15:13:23 EDT 2008
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
|
||||
org.eclipse.jdt.core.codeComplete.fieldPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.fieldSuffixes=
|
||||
org.eclipse.jdt.core.codeComplete.localPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.localSuffixes=
|
||||
org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
|
||||
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,7 @@
|
|||
* This is the ant build file for ICU4J Locale SPI implementation.
|
||||
*/
|
||||
-->
|
||||
<project name="icu4j-localespi" default="build" basedir=".">
|
||||
<project name="icu4j-localespi" default="build-jar" basedir=".">
|
||||
<property file="../build.properties"/>
|
||||
<property name="build.dir" value="classes"/>
|
||||
<property name="src.dir" value="src"/>
|
||||
|
@ -15,19 +15,13 @@
|
|||
<property name="javac.bin.ver" value="1.6"/>
|
||||
<property name="jar.file" value="icu4j-localespi.jar"/>
|
||||
<property name="icu4j.jar.file" value="../icu4j.jar"/>
|
||||
<property name="icu4j.build.dir" value="../classes"/>
|
||||
<property name="icu4j.core.build.file" value="../build.xml"/>
|
||||
<property name="ext.dir" value="ext"/>
|
||||
<condition property="is.java6">
|
||||
<contains string="${java.version}" substring="1.6."/>
|
||||
</condition>
|
||||
|
||||
<target name="init" depends="check-env-java6">
|
||||
<mkdir dir="${build.dir}"/>
|
||||
<copy todir="${build.dir}/META-INF">
|
||||
<fileset dir="${src.dir}/META-INF" includes="**/*"/>
|
||||
</copy>
|
||||
<copy todir="${build.dir}">
|
||||
<fileset dir="${src.dir}" includes="**/*.properties"/>
|
||||
</copy>
|
||||
</target>
|
||||
<available file="${icu4j.jar.file}" property="is.icu4j.jar.available"/>
|
||||
|
||||
<target name="check-env-java6" unless="is.java6">
|
||||
<echo message="######################## ERROR ########################"/>
|
||||
|
@ -37,17 +31,37 @@
|
|||
<fail message="Java SE 6 SDK is required"/>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="init">
|
||||
<target name="icu4j-jar" unless="is.icu4j.jar.available">
|
||||
<!-- Building icu4j.jar if missing. We do not want to build
|
||||
icu4j.jar here, because Java 6 is not the standard JDK
|
||||
for icu4j core library. -->
|
||||
<echo message="WARNING: Building icu4j.jar with Java 6"/>
|
||||
<ant antfile="${icu4j.core.build.file}" target="jar" inheritAll="false"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="check-env-java6,icu4j-jar">
|
||||
<mkdir dir="${build.dir}"/>
|
||||
<javac srcdir="${src.dir}"
|
||||
includes="com/ibm/icu/impl/**/*.java"
|
||||
destdir="${build.dir}"
|
||||
classpath="${icu4j.jar.file}"
|
||||
source="${javac.src.ver}"
|
||||
target="${javac.bin.ver}"
|
||||
debug="on"
|
||||
encoding="ascii"/>
|
||||
<jar jarfile="${jar.file}" compress="true">
|
||||
<fileset dir="../" includes="license.html"/>
|
||||
<fileset dir="${build.dir}" includes="**/*"/>
|
||||
encoding="ascii">
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="jar">
|
||||
<jar jarfile="${jar.file}" compress="true">
|
||||
<fileset dir="${src.dir}">
|
||||
<include name="META-INF/services/java.*Provider"/>
|
||||
<include name="com/ibm/icu/impl/javaspi/ICUProvider.properties"/>
|
||||
</fileset>
|
||||
<fileset dir="${build.dir}">
|
||||
<include name="com/ibm/icu/impl/**/*"/>
|
||||
</fileset>
|
||||
<fileset dir="../" includes="license.html"/>
|
||||
<manifest>
|
||||
<attribute name="Built-By" value="${corp}"/>
|
||||
<section name="common">
|
||||
|
@ -65,9 +79,41 @@
|
|||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="tests" depends="check-env-java6">
|
||||
<ant antfile="${icu4j.core.build.file}" target="tests" inheritAll="false"/>
|
||||
<javac srcdir="${src.dir}"
|
||||
includes="com/ibm/icu/dev/test/**/*.java"
|
||||
destdir="${build.dir}"
|
||||
classpath="${icu4j.build.dir}"
|
||||
source="${javac.src.ver}"
|
||||
target="${javac.bin.ver}"
|
||||
debug="on"
|
||||
encoding="ascii">
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="run-check">
|
||||
<mkdir dir="${ext.dir}"/>
|
||||
<copy file="${icu4j.jar.file}" todir="${ext.dir}"/>
|
||||
<copy file="${jar.file}" todir="${ext.dir}"/>
|
||||
|
||||
<java classname="com.ibm.icu.dev.test.localespi.TestAll" fork="yes" failonerror="true">
|
||||
<jvmarg line="-Djava.ext.dirs=${ext.dir}"/>
|
||||
<arg value="-n" />
|
||||
<classpath>
|
||||
<pathelement path="${build.dir}" />
|
||||
<pathelement path="${icu4j.build.dir}/"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete file="${jar.file}"/>
|
||||
<delete dir="${ext.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="build-jar" depends="compile,jar"/>
|
||||
<target name="check" depends="build-jar,tests,run-check"/>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.localespi;
|
||||
|
||||
import java.text.BreakIterator;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
|
||||
public class BreakIteratorTest extends TestFmwk {
|
||||
public static void main(String[] args) throws Exception {
|
||||
new BreakIteratorTest().run(args);
|
||||
}
|
||||
|
||||
private static final int CHARACTER_BRK = 0;
|
||||
private static final int WORD_BRK = 1;
|
||||
private static final int LINE_BRK = 2;
|
||||
private static final int SENTENCE_BRK = 3;
|
||||
|
||||
public void TestGetInstance() {
|
||||
for (Locale loc : TestUtil.getICULocales()) {
|
||||
checkGetInstance(CHARACTER_BRK, loc);
|
||||
checkGetInstance(WORD_BRK, loc);
|
||||
checkGetInstance(LINE_BRK, loc);
|
||||
checkGetInstance(SENTENCE_BRK, loc);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGetInstance(int type, Locale loc) {
|
||||
BreakIterator brkitr = null;
|
||||
String method = null;
|
||||
switch (type) {
|
||||
case CHARACTER_BRK:
|
||||
brkitr = BreakIterator.getCharacterInstance(loc);
|
||||
method = "getCharacterInstance";
|
||||
break;
|
||||
case WORD_BRK:
|
||||
brkitr = BreakIterator.getWordInstance(loc);
|
||||
method = "getWordInstance";
|
||||
break;
|
||||
case LINE_BRK:
|
||||
brkitr = BreakIterator.getLineInstance(loc);
|
||||
method = "getLineInstance";
|
||||
break;
|
||||
case SENTENCE_BRK:
|
||||
brkitr = BreakIterator.getSentenceInstance(loc);
|
||||
method = "getSentenceInstance";
|
||||
break;
|
||||
default:
|
||||
errln("FAIL: Unknown break iterator type");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TestUtil.isICUOnly(loc)) {
|
||||
if (!(brkitr instanceof com.ibm.icu.impl.jdkadapter.BreakIteratorICU)) {
|
||||
errln("FAIL: " + method + " returned JDK BreakIterator for locale " + loc);
|
||||
}
|
||||
} else {
|
||||
if (brkitr instanceof com.ibm.icu.impl.jdkadapter.BreakIteratorICU) {
|
||||
logln("INFO: " + method + " returned ICU BreakIterator for locale " + loc);
|
||||
} else {
|
||||
Locale iculoc = TestUtil.toICUExtendedLocale(loc);
|
||||
switch (type) {
|
||||
case CHARACTER_BRK:
|
||||
brkitr = BreakIterator.getCharacterInstance(iculoc);
|
||||
break;
|
||||
case WORD_BRK:
|
||||
brkitr = BreakIterator.getWordInstance(iculoc);
|
||||
break;
|
||||
case LINE_BRK:
|
||||
brkitr = BreakIterator.getLineInstance(iculoc);
|
||||
break;
|
||||
case SENTENCE_BRK:
|
||||
brkitr = BreakIterator.getSentenceInstance(iculoc);
|
||||
break;
|
||||
}
|
||||
if (!(brkitr instanceof com.ibm.icu.impl.jdkadapter.BreakIteratorICU)) {
|
||||
errln("FAIL: " + method + " returned JDK BreakIterator for locale " + iculoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.localespi;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
|
||||
public class CollatorTest extends TestFmwk {
|
||||
public static void main(String[] args) throws Exception {
|
||||
new CollatorTest().run(args);
|
||||
}
|
||||
|
||||
public void TestGetInstance() {
|
||||
for (Locale loc : TestUtil.getICULocales()) {
|
||||
Collator coll = Collator.getInstance(loc);
|
||||
if (TestUtil.isICUOnly(loc)) {
|
||||
if (!(coll instanceof com.ibm.icu.impl.jdkadapter.CollatorICU)) {
|
||||
errln("FAIL: getInstance returned JDK Collator for locale " + loc);
|
||||
}
|
||||
} else {
|
||||
if (coll instanceof com.ibm.icu.impl.jdkadapter.CollatorICU) {
|
||||
logln("INFO: getInstance returned ICU Collator for locale " + loc);
|
||||
} else {
|
||||
Locale iculoc = TestUtil.toICUExtendedLocale(loc);
|
||||
coll = Collator.getInstance(iculoc);
|
||||
if (!(coll instanceof com.ibm.icu.impl.jdkadapter.CollatorICU)) {
|
||||
errln("FAIL: getInstance returned JDK Collator for locale " + iculoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.localespi;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
|
||||
public class DateFormatSymbolsTest extends TestFmwk {
|
||||
public static void main(String[] args) throws Exception {
|
||||
new DateFormatSymbolsTest().run(args);
|
||||
}
|
||||
|
||||
public void TestGetInstance() {
|
||||
for (Locale loc : TestUtil.getICULocales()) {
|
||||
DateFormatSymbols dfs = DateFormatSymbols.getInstance(loc);
|
||||
if (TestUtil.isICUOnly(loc)) {
|
||||
if (!(dfs instanceof com.ibm.icu.impl.jdkadapter.DateFormatSymbolsICU)) {
|
||||
errln("FAIL: getInstance returned JDK DateFormatSymbols for locale " + loc);
|
||||
}
|
||||
} else {
|
||||
if (dfs instanceof com.ibm.icu.impl.jdkadapter.DateFormatSymbolsICU) {
|
||||
logln("INFO: getInstance returned ICU DateFormatSymbols for locale " + loc);
|
||||
} else {
|
||||
Locale iculoc = TestUtil.toICUExtendedLocale(loc);
|
||||
dfs = DateFormatSymbols.getInstance(iculoc);
|
||||
if (!(dfs instanceof com.ibm.icu.impl.jdkadapter.DateFormatSymbolsICU)) {
|
||||
errln("FAIL: getInstance returned JDK DateFormatSymbols for locale " + iculoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.localespi;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
|
||||
public class DateFormatTest extends TestFmwk {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new DateFormatTest().run(args);
|
||||
}
|
||||
|
||||
public void TestGetInstance() {
|
||||
for (Locale loc : TestUtil.getICULocales()) {
|
||||
checkGetInstance(DateFormat.FULL, DateFormat.LONG, loc);
|
||||
checkGetInstance(DateFormat.MEDIUM, -1, loc);
|
||||
checkGetInstance(1, DateFormat.SHORT, loc);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGetInstance(int dstyle, int tstyle, Locale loc) {
|
||||
DateFormat df;
|
||||
String method;
|
||||
if (dstyle < 0) {
|
||||
df = DateFormat.getTimeInstance(DateFormat.SHORT, loc);
|
||||
method = "getTimeInstance";
|
||||
} else if (tstyle < 0) {
|
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM, loc);
|
||||
method = "getDateInstance";
|
||||
} else {
|
||||
df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.LONG, loc);
|
||||
method = "getDateTimeInstance";
|
||||
}
|
||||
if (TestUtil.isICUOnly(loc)) {
|
||||
if (!(df instanceof com.ibm.icu.impl.jdkadapter.SimpleDateFormatICU)) {
|
||||
errln("FAIL: " + method + " returned JDK DateFormat for locale " + loc);
|
||||
}
|
||||
} else {
|
||||
if (df instanceof com.ibm.icu.impl.jdkadapter.SimpleDateFormatICU) {
|
||||
logln("INFO: " + method + " returned ICU DateFormat for locale " + loc);
|
||||
} else {
|
||||
Locale iculoc = TestUtil.toICUExtendedLocale(loc);
|
||||
if (dstyle < 0) {
|
||||
df = DateFormat.getTimeInstance(DateFormat.SHORT, iculoc);
|
||||
} else if (tstyle < 0) {
|
||||
df = DateFormat.getDateInstance(DateFormat.MEDIUM, iculoc);
|
||||
} else {
|
||||
df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.LONG, iculoc);
|
||||
}
|
||||
if (!(df instanceof com.ibm.icu.impl.jdkadapter.SimpleDateFormatICU)) {
|
||||
errln("FAIL: " + method + " returned JDK DateFormat for locale " + iculoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.localespi;
|
||||
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
|
||||
public class DecimalFormatSymbolsTest extends TestFmwk {
|
||||
public static void main(String[] args) throws Exception {
|
||||
new DecimalFormatSymbolsTest().run(args);
|
||||
}
|
||||
|
||||
public void TestGetInstance() {
|
||||
for (Locale loc : TestUtil.getICULocales()) {
|
||||
DecimalFormatSymbols decfs = DecimalFormatSymbols.getInstance(loc);
|
||||
if (TestUtil.isICUOnly(loc)) {
|
||||
if (!(decfs instanceof com.ibm.icu.impl.jdkadapter.DecimalFormatSymbolsICU)) {
|
||||
errln("FAIL: getInstance returned JDK DecimalFormatSymbols for locale " + loc);
|
||||
}
|
||||
} else {
|
||||
if (decfs instanceof com.ibm.icu.impl.jdkadapter.DecimalFormatSymbolsICU) {
|
||||
logln("INFO: getInstance returned ICU DecimalFormatSymbols for locale " + loc);
|
||||
} else {
|
||||
Locale iculoc = TestUtil.toICUExtendedLocale(loc);
|
||||
decfs = DecimalFormatSymbols.getInstance(iculoc);
|
||||
if (!(decfs instanceof com.ibm.icu.impl.jdkadapter.DecimalFormatSymbolsICU)) {
|
||||
errln("FAIL: getInstance returned JDK DecimalFormatSymbols for locale " + iculoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.localespi;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
|
||||
public class NumberFormatTest extends TestFmwk {
|
||||
public static void main(String[] args) throws Exception {
|
||||
new NumberFormatTest().run(args);
|
||||
}
|
||||
|
||||
private static final int DEFAULT_TYPE = 0;
|
||||
private static final int NUMBER_TYPE = 1;
|
||||
private static final int INTEGER_TYPE = 2;
|
||||
private static final int PERCENT_TYPE = 3;
|
||||
private static final int CURRENCY_TYPE = 4;
|
||||
|
||||
public void TestGetInstance() {
|
||||
for (Locale loc : TestUtil.getICULocales()) {
|
||||
checkGetInstance(DEFAULT_TYPE, loc);
|
||||
checkGetInstance(NUMBER_TYPE, loc);
|
||||
checkGetInstance(INTEGER_TYPE, loc);
|
||||
checkGetInstance(PERCENT_TYPE, loc);
|
||||
checkGetInstance(CURRENCY_TYPE, loc);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGetInstance(int type, Locale loc) {
|
||||
NumberFormat nf = null;
|
||||
String method = null;
|
||||
|
||||
switch (type) {
|
||||
case DEFAULT_TYPE:
|
||||
nf = NumberFormat.getInstance(loc);
|
||||
method = "getInstance";
|
||||
break;
|
||||
case NUMBER_TYPE:
|
||||
nf = NumberFormat.getNumberInstance(loc);
|
||||
method = "getNumberInstance";
|
||||
break;
|
||||
case INTEGER_TYPE:
|
||||
nf = NumberFormat.getIntegerInstance(loc);
|
||||
method = "getIntegerInstance";
|
||||
break;
|
||||
case PERCENT_TYPE:
|
||||
nf = NumberFormat.getPercentInstance(loc);
|
||||
method = "getPercentInstance";
|
||||
break;
|
||||
case CURRENCY_TYPE:
|
||||
nf = NumberFormat.getCurrencyInstance(loc);
|
||||
method = "getCurrencyInstance";
|
||||
break;
|
||||
default:
|
||||
errln("FAIL: Unknown number format type");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TestUtil.isICUOnly(loc)) {
|
||||
if (!(nf instanceof com.ibm.icu.impl.jdkadapter.DecimalFormatICU)) {
|
||||
errln("FAIL: " + method + " returned JDK NumberFormat for locale " + loc);
|
||||
}
|
||||
} else {
|
||||
if (nf instanceof com.ibm.icu.impl.jdkadapter.DecimalFormatICU) {
|
||||
logln("INFO: " + method + " returned ICU NumberFormat for locale " + loc);
|
||||
} else {
|
||||
Locale iculoc = TestUtil.toICUExtendedLocale(loc);
|
||||
switch (type) {
|
||||
case DEFAULT_TYPE:
|
||||
nf = NumberFormat.getInstance(iculoc);
|
||||
method = "getInstance";
|
||||
break;
|
||||
case NUMBER_TYPE:
|
||||
nf = NumberFormat.getNumberInstance(iculoc);
|
||||
method = "getNumberInstance";
|
||||
break;
|
||||
case INTEGER_TYPE:
|
||||
nf = NumberFormat.getIntegerInstance(iculoc);
|
||||
method = "getIntegerInstance";
|
||||
break;
|
||||
case PERCENT_TYPE:
|
||||
nf = NumberFormat.getPercentInstance(iculoc);
|
||||
method = "getPercentInstance";
|
||||
break;
|
||||
case CURRENCY_TYPE:
|
||||
nf = NumberFormat.getCurrencyInstance(iculoc);
|
||||
method = "getCurrencyInstance";
|
||||
break;
|
||||
}
|
||||
if (!(nf instanceof com.ibm.icu.impl.jdkadapter.DecimalFormatICU)) {
|
||||
errln("FAIL: " + method + " returned JDK NumberFormat for locale " + iculoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.localespi;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk.TestGroup;
|
||||
|
||||
public class TestAll extends TestGroup {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new TestAll().run(args);
|
||||
}
|
||||
|
||||
public TestAll() {
|
||||
super(new String[] {
|
||||
"BreakIteratorTest",
|
||||
"CollatorTest",
|
||||
"DateFormatSymbolsTest",
|
||||
"DateFormatTest",
|
||||
"DecimalFormatSymbolsTest",
|
||||
"NumberFormatTest",
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2008, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.localespi;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.icu.impl.ICUResourceBundle;
|
||||
|
||||
public class TestUtil {
|
||||
|
||||
private static final Locale[] JDK_LOCALES = Locale.getAvailableLocales();
|
||||
private static final Locale[] ICU_LOCALES = ICUResourceBundle.getAvailableLocales();
|
||||
private static final Locale[] ICU_ONLY_LOCALES;
|
||||
private static final Set<Locale> JDK_LOCALE_SET = new HashSet<Locale>();
|
||||
private static final Set<Locale> ICU_LOCALE_SET = new HashSet<Locale>();
|
||||
private static final Set<Locale> ICU_ONLY_LOCALE_SET = new HashSet<Locale>();
|
||||
|
||||
private static final String ICU_VARIANT = "ICU";
|
||||
private static final String ICU_VARIANT_SUFFIX = "_ICU";
|
||||
|
||||
static {
|
||||
for (Locale jdkloc : JDK_LOCALES) {
|
||||
JDK_LOCALE_SET.add(jdkloc);
|
||||
}
|
||||
|
||||
for (Locale iculoc : ICU_LOCALES) {
|
||||
ICU_LOCALE_SET.add(iculoc);
|
||||
if (!JDK_LOCALE_SET.contains(iculoc)) {
|
||||
ICU_ONLY_LOCALE_SET.add(iculoc);
|
||||
}
|
||||
}
|
||||
ICU_ONLY_LOCALES = ICU_ONLY_LOCALE_SET.toArray(new Locale[0]);
|
||||
}
|
||||
|
||||
public static boolean isICUOnly(Locale locale) {
|
||||
return ICU_ONLY_LOCALE_SET.contains(locale);
|
||||
}
|
||||
|
||||
public static Locale[] getICUOnlyLocales() {
|
||||
return Arrays.copyOf(ICU_ONLY_LOCALES, ICU_ONLY_LOCALES.length);
|
||||
}
|
||||
|
||||
public static Locale[] getJDKLocales() {
|
||||
return Arrays.copyOf(JDK_LOCALES, JDK_LOCALES.length);
|
||||
}
|
||||
|
||||
public static Locale[] getICULocales() {
|
||||
return Arrays.copyOf(ICU_LOCALES, ICU_LOCALES.length);
|
||||
}
|
||||
|
||||
public static Locale toICUExtendedLocale(Locale locale) {
|
||||
if (isICUExtendedLocale(locale)) {
|
||||
return locale;
|
||||
}
|
||||
String variant = locale.getVariant();
|
||||
variant = variant.length() == 0 ? ICU_VARIANT : variant + ICU_VARIANT_SUFFIX;
|
||||
return new Locale(locale.getLanguage(), locale.getCountry(), variant);
|
||||
}
|
||||
|
||||
public static boolean isICUExtendedLocale(Locale locale) {
|
||||
String variant = locale.getVariant();
|
||||
if (variant.equals(ICU_VARIANT) || variant.endsWith(ICU_VARIANT_SUFFIX)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ import com.ibm.icu.impl.javaspi.ICULocale;
|
|||
import com.ibm.icu.lang.UCharacter;
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
|
||||
public class TimeZoneNameProvider extends java.util.spi.TimeZoneNameProvider {
|
||||
public class TimeZoneNameProviderICU extends java.util.spi.TimeZoneNameProvider {
|
||||
|
||||
@Override
|
||||
public String getDisplayName(String ID, boolean daylight, int style, Locale locale) {
|
Loading…
Add table
Reference in a new issue