test/jdk/java/util/ResourceBundle/Bug6299235/Bug6299235Test.java
author dzhou
Thu, 15 Nov 2018 21:53:30 -0800
changeset 52584 5ab248e47901
parent 47216 test/jdk/java/util/ResourceBundle/Bug6299235Test.java@71c04702a3d5
permissions -rw-r--r--
8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests Reviewed-by: naoto
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
52584
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
     2
 * Copyright (c) 2007, 2018, 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
 */
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    23
52584
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    24
/*
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    25
 * @test
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    26
 * @bug 6299235 8210408
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    27
 * @summary test Bug 6299235 to make sure the third-party provided sun resources
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    28
 *          could be picked up.
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    29
 * @modules java.desktop
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    30
 * @library patches
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    31
 * @build java.desktop/sun.awt.resources.awt_ru_RU
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    32
 * @run main Bug6299235Test
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    33
 */
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    34
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    35
import java.awt.Toolkit;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * After introducing CoreResourceBundleControl for Awt/Swing resources
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * loading, non-existent resources won't be actually searched from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * bootclasspath and extension directory. But we should still fallback
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * to the current behavior which allows the third-part to provide their
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * own version of awt resources, for example even though we never claim
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * we support it yet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Look into bug 6299235 for more details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
public class Bug6299235Test {
52584
5ab248e47901 8210408: Refactor java.util.ResourceBundle:i18n shell tests to plain java tests
dzhou
parents: 47216
diff changeset
    49
    private static final Locale ru_RU = new Locale("ru", "RU");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    51
    public static void main(String args[]) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    52
        Locale locale = Locale.getDefault();
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    53
        try {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    54
            Locale.setDefault(ru_RU);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    55
            // Get the value for the test key "foo"
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    56
            String value = Toolkit.getProperty("foo", "undefined");
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    57
            if (!value.equals("bar")) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    58
                throw new RuntimeException("key = foo, value = " + value);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            }
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    60
            // Get the value for a valid key "AWT.enter"
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    61
            value = Toolkit.getProperty("AWT.enter", "DO NOT ENTER");
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    62
            if (value.equals("DO NOT ENTER")) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    63
                throw new RuntimeException("AWT.enter undefined.");
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    64
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    65
        } finally {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    66
            // Restore the default Locale
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    67
            Locale.setDefault(locale);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        }
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 5506
diff changeset
    69
        System.out.println("Bug6299235Test passed");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
}