jdk/test/java/util/PluggableLocale/DateFormatProviderTest.java
author lana
Thu, 26 Dec 2013 12:04:16 -0800
changeset 23010 6dadb192ad81
parent 15260 7af2d7a87806
permissions -rw-r--r--
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013 Summary: updated files with 2011, 2012 and 2013 years according to the file's last updated date Reviewed-by: tbell, lancea, chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 15260
diff changeset
     2
 * Copyright (c) 2007, 2013, 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.*;
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    29
import sun.util.locale.provider.*;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.util.resources.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
public class DateFormatProviderTest extends ProviderTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    com.foo.DateFormatProviderImpl dfp = new com.foo.DateFormatProviderImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    List<Locale> availloc = Arrays.asList(DateFormat.getAvailableLocales());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    List<Locale> providerloc = Arrays.asList(dfp.getAvailableLocales());
14418
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    37
    List<Locale> jreloc = Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales());
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    38
    List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getDateFormatProvider().getAvailableLocales());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    public static void main(String[] s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        new DateFormatProviderTest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    DateFormatProviderTest() {
14418
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    45
        availableLocalesTest();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        objectValidityTest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        extendedVariantTest();
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
14418
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    51
    void availableLocalesTest() {
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    52
        Set<Locale> localesFromAPI = new HashSet<>(availloc);
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    53
        Set<Locale> localesExpected = new HashSet<>(jreloc);
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    54
        localesExpected.addAll(providerloc);
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    55
        if (localesFromAPI.equals(localesExpected)) {
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    56
            System.out.println("availableLocalesTest passed.");
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    57
        } else {
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    58
            throw new RuntimeException("availableLocalesTest failed");
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    59
        }
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    60
    }
967376921f20 8001205: Calendar.getDisplayName(...): Returns null when provider is SPI but there is no SPI implementation
naoto
parents: 13583
diff changeset
    61
2
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
            // Get the key for the date/time patterns which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            // specific to each calendar system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            Calendar cal = Calendar.getInstance(target);
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    68
            String dkey = "DatePatterns";
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    69
            String tkey = "TimePatterns";
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    70
            String dtkey = "DateTimePatterns";
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    71
            switch (cal.getCalendarType()) {
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    72
                case "java.util.JapaneseImperialCalendar":
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    73
                    dkey = "japanese"+ "." + dkey;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    74
                    tkey = "japanese"+ "." + tkey;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    75
                    dtkey = "japanese"+ "." + dtkey;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    76
                    break;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    77
                case "sun.util.BuddhistCalendar":
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    78
                    dkey = "buddhist"+ "." + dkey;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    79
                    tkey = "buddhist"+ "." + tkey;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    80
                    dtkey = "buddhist"+ "." + dtkey;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    81
                    break;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    82
                case "java.util.GregorianCalendar":
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    83
                default:
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    84
                    break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            // pure JRE implementation
15260
7af2d7a87806 7162007: Clean up i18n related caches
naoto
parents: 14418
diff changeset
    87
            ResourceBundle rb = ((ResourceBundleBasedAdapter)LocaleProviderAdapter.forJRE()).getLocaleData().getDateFormatData(target);
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    88
            boolean jreSupportsLocale = jreimplloc.contains(target);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            // JRE string arrays
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    91
            String[] jreDatePatterns = null;
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    92
            String[] jreTimePatterns = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            String[] jreDateTimePatterns = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            if (jreSupportsLocale) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                try {
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    96
                    jreDatePatterns = (String[])rb.getObject(dkey);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    97
                    jreTimePatterns = (String[])rb.getObject(tkey);
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
    98
                    jreDateTimePatterns = (String[])rb.getObject(dtkey);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                } catch (MissingResourceException mre) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            for (int style = DateFormat.FULL; style <= DateFormat.SHORT; style ++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                // result object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                DateFormat result = DateFormat.getDateTimeInstance(style, style, target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                // provider's object (if any)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                DateFormat providersResult = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                if (providerloc.contains(target)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                    providersResult = dfp.getDateTimeInstance(style, style, target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                // JRE's object (if any)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                DateFormat jresResult = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                if (jreSupportsLocale) {
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
   115
                    Object[] dateTimeArgs = {jreTimePatterns[style],
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
   116
                                             jreDatePatterns[style]};
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 7787
diff changeset
   117
                    String pattern = MessageFormat.format(jreDateTimePatterns[0], dateTimeArgs);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                    jresResult = new SimpleDateFormat(pattern, target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                checkValidity(target, jresResult, providersResult, result, jreSupportsLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    // Check that fallback correctly occurs with locales with variant including '_'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    // This test assumes that the provider supports the ja_JP_osaka locale, and JRE does not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    void extendedVariantTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        Locale[] testlocs = {new Locale("ja", "JP", "osaka_extended"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                             new Locale("ja", "JP", "osaka_extended_further"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                             new Locale("ja", "JP", "osaka_")};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        for (Locale test: testlocs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, test);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            DateFormat provider = dfp.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, test);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            if (!df.equals(provider)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                throw new RuntimeException("variant fallback failed. test locale: "+test);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
7787
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   140
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   141
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   142
    private static final String[] TYPES = {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   143
        "date",
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   144
        "time"
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   145
    };
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   146
    private static final String[] MODIFIERS = {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   147
        "",
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   148
        "short",
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   149
        "medium", // Same as DEFAULT
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   150
        "long",
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   151
        "full"
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   152
    };
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   153
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   154
    void messageFormatTest() {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   155
        for (Locale target : providerloc) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   156
            for (String type : TYPES) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   157
                for (String modifier : MODIFIERS) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   158
                    String pattern, expected;
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   159
                    if (modifier.equals("")) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   160
                        pattern = String.format("%s={0,%s}", type, type);
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   161
                    } else {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   162
                        pattern = String.format("%s={0,%s,%s}", type, type, modifier);
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   163
                    }
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   164
                    if (modifier.equals("medium")) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   165
                        // medium is default.
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   166
                        expected = String.format("%s={0,%s}", type, type);
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   167
                    } else {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   168
                        expected = pattern;
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   169
                    }
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   170
                    MessageFormat mf = new MessageFormat(pattern, target);
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   171
                    Format[] fmts = mf.getFormats();
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   172
                    if (fmts[0] instanceof SimpleDateFormat) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   173
                        continue;
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   174
                    }
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   175
                    String toPattern = mf.toPattern();
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   176
                    if (!toPattern.equals(expected)) {
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   177
                        throw new RuntimeException("messageFormatTest: got '" + toPattern
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   178
                                                   + "', expected '" + expected + "'");
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   179
                    }
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
            }
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   182
        }
d2420a14d0a2 7003643: [Fmt-Me] MessageFormat.toPattern produces wrong quoted string and subformat modifiers
okutsu
parents: 5506
diff changeset
   183
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
}