jdk/test/java/util/ResourceBundle/Bug6190861.java
author rupashka
Mon, 17 May 2010 17:23:18 +0400
changeset 5581 9c2282c6f080
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6938481: 4906607 is not fixed for NIMBUS L&F Reviewed-by: alexp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @bug 6190861
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @summary Make sure to always load the default locale's bundle when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * there's no bundle for the requested locale.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
public class Bug6190861 {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    static public void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
        Locale.setDefault(new Locale("en", "US"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
        List localeList = new ArrayList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        localeList.add(Locale.ENGLISH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        localeList.add(Locale.KOREA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        localeList.add(Locale.UK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        localeList.add(new Locale("en", "CA"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        localeList.add(Locale.ENGLISH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        Iterator iter = localeList.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        while (iter.hasNext()){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
            Locale currentLocale = (Locale) iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
            System.out.println("\ncurrentLocale = "
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
                               + currentLocale.getDisplayName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            ResourceBundle messages = ResourceBundle.getBundle("Bug6190861Data",currentLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            Locale messagesLocale = messages.getLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            System.out.println("messagesLocale = "
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
                               + messagesLocale.getDisplayName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            checkMessages(messages);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static void checkMessages(ResourceBundle messages) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        String greetings = messages.getString("greetings");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        String inquiry = messages.getString("inquiry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        String farewell = messages.getString("farewell");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        System.out.println(greetings);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        System.out.println(inquiry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        System.out.println(farewell);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        if (!greetings.equals("Hiya.")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            throw new RuntimeException("got wrong resource bundle");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
}