jdk/test/java/util/PluggableLocale/NumberFormatProviderTest.java
author xuelei
Fri, 29 Jul 2011 02:50:58 -0700
changeset 10138 b7572da25d15
parent 7787 d2420a14d0a2
child 13583 dc0017b1a452
permissions -rw-r--r--
7068662: Reserve and restore the default locale Reviewed-by: alanb, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
     2
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.text.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import sun.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.util.resources.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    32
import com.foo.FooNumberFormat;
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    33
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
public class NumberFormatProviderTest extends ProviderTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    com.foo.NumberFormatProviderImpl nfp = new com.foo.NumberFormatProviderImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    List<Locale> availloc = Arrays.asList(NumberFormat.getAvailableLocales());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    List<Locale> providerloc = Arrays.asList(nfp.getAvailableLocales());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    List<Locale> jreloc = Arrays.asList(LocaleData.getAvailableLocales());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    public static void main(String[] s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        new NumberFormatProviderTest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    NumberFormatProviderTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        availableLocalesTest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        objectValidityTest();
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    48
        messageFormatTest();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    void availableLocalesTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        Set<Locale> localesFromAPI = new HashSet<Locale>(availloc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        Set<Locale> localesExpected = new HashSet<Locale>(jreloc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        localesExpected.addAll(providerloc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        if (localesFromAPI.equals(localesExpected)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            System.out.println("availableLocalesTest passed.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            throw new RuntimeException("availableLocalesTest failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    void objectValidityTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        for (Locale target: availloc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            // pure JRE implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            ResourceBundle rb = LocaleData.getNumberFormatData(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            boolean jreSupportsLocale = jreloc.contains(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            // JRE string arrays
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            String[] jreNumberPatterns = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            if (jreSupportsLocale) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                    jreNumberPatterns = rb.getStringArray("NumberPatterns");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                } catch (MissingResourceException mre) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            // result object
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    78
            String resultCur = getPattern(NumberFormat.getCurrencyInstance(target));
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    79
            String resultInt = getPattern(NumberFormat.getIntegerInstance(target));
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    80
            String resultNum = getPattern(NumberFormat.getNumberInstance(target));
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    81
            String resultPer = getPattern(NumberFormat.getPercentInstance(target));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            // provider's object (if any)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            String providersCur = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            String providersInt = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            String providersNum = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            String providersPer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            if (providerloc.contains(target)) {
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    89
                NumberFormat dfCur = nfp.getCurrencyInstance(target);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                if (dfCur != null) {
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    91
                    providersCur = getPattern(dfCur);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                }
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    93
                NumberFormat dfInt = nfp.getIntegerInstance(target);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                if (dfInt != null) {
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    95
                    providersInt = getPattern(dfInt);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                }
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    97
                NumberFormat dfNum = nfp.getNumberInstance(target);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                if (dfNum != null) {
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
    99
                    providersNum = getPattern(dfNum);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                }
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   101
                NumberFormat dfPer = nfp.getPercentInstance(target);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                if (dfPer != null) {
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   103
                    providersPer = getPattern(dfPer);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            // JRE's object (if any)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            // note that this totally depends on the current implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            String jresCur = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            String jresInt = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            String jresNum = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            String jresPer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            if (jreSupportsLocale) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                DecimalFormat dfCur = new DecimalFormat(jreNumberPatterns[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                    DecimalFormatSymbols.getInstance(target));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                if (dfCur != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                    adjustForCurrencyDefaultFractionDigits(dfCur);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                    jresCur = dfCur.toPattern();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                DecimalFormat dfInt = new DecimalFormat(jreNumberPatterns[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                    DecimalFormatSymbols.getInstance(target));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                if (dfInt != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                    dfInt.setMaximumFractionDigits(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                    dfInt.setDecimalSeparatorAlwaysShown(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                    dfInt.setParseIntegerOnly(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                    jresInt = dfInt.toPattern();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                DecimalFormat dfNum = new DecimalFormat(jreNumberPatterns[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                    DecimalFormatSymbols.getInstance(target));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                if (dfNum != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                    jresNum = dfNum.toPattern();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                DecimalFormat dfPer = new DecimalFormat(jreNumberPatterns[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                    DecimalFormatSymbols.getInstance(target));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                if (dfPer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                    jresPer = dfPer.toPattern();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            checkValidity(target, jresCur, providersCur, resultCur, jreSupportsLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            checkValidity(target, jresInt, providersInt, resultInt, jreSupportsLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            checkValidity(target, jresNum, providersNum, resultNum, jreSupportsLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            checkValidity(target, jresPer, providersPer, resultPer, jreSupportsLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Adjusts the minimum and maximum fraction digits to values that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * are reasonable for the currency's default fraction digits.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    void adjustForCurrencyDefaultFractionDigits(DecimalFormat df) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        Currency currency = dfs.getCurrency();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        if (currency == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                currency = Currency.getInstance(dfs.getInternationalCurrencySymbol());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if (currency != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            int digits = currency.getDefaultFractionDigits();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            if (digits != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                int oldMinDigits = df.getMinimumFractionDigits();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                // Common patterns are "#.##", "#.00", "#".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                // Try to adjust all of them in a reasonable way.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                if (oldMinDigits == df.getMaximumFractionDigits()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    df.setMinimumFractionDigits(digits);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    df.setMaximumFractionDigits(digits);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    df.setMinimumFractionDigits(Math.min(digits, oldMinDigits));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                    df.setMaximumFractionDigits(digits);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   176
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   177
    private static String getPattern(NumberFormat nf) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   178
        if (nf instanceof DecimalFormat) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   179
            return ((DecimalFormat)nf).toPattern();
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   180
        }
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   181
        if (nf instanceof FooNumberFormat) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   182
            return ((FooNumberFormat)nf).toPattern();
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   183
        }
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   184
        return null;
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   185
    }
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   186
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   187
    private static final String[] NUMBER_PATTERNS = {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   188
        "num={0,number}",
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   189
        "num={0,number,currency}",
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   190
        "num={0,number,percent}",
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   191
        "num={0,number,integer}"
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   192
    };
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   193
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   194
    void messageFormatTest() {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   195
        for (Locale target : providerloc) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   196
            for (String pattern : NUMBER_PATTERNS) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   197
                MessageFormat mf = new MessageFormat(pattern, target);
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   198
                String toPattern = mf.toPattern();
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   199
                if (!pattern.equals(toPattern)) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   200
                    throw new RuntimeException("MessageFormat.toPattern: got '"
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   201
                                               + toPattern
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   202
                                               + "', expected '" + pattern + "'");
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   203
                }
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   204
            }
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   205
        }
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   206
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
}