1 /*
2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.
8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 import java.util.Locale;
25 
26 import javax.accessibility.AccessibleBundle;
27 
28 import static javax.accessibility.AccessibleRole.ALERT;
29 import static javax.accessibility.AccessibleRole.LABEL;
30 import static javax.accessibility.AccessibleRole.PANEL;
31 import static javax.accessibility.AccessibleState.MANAGES_DESCENDANTS;
32 
33 /**
34  * @test
35  * @bug 8213516
36  * @summary Checks basic functionality of AccessibleBundle class
37  */
38 public final class Basic extends AccessibleBundle {
39 
Basic(final String key)40     private Basic(final String key) {
41         this.key = key;
42     }
43 
main(final String[] args)44     public static void main(final String[] args) {
45         testStandardResource();
46         testCustomResource();
47     }
48 
testCustomResource()49     private static void testCustomResource() {
50         final Basic bundle = new Basic("managesDescendants");
51         test(bundle.toDisplayString(Locale.ENGLISH), "manages descendants");
52         test(bundle.toDisplayString("NonExistedBundle", Locale.ENGLISH),
53              "managesDescendants");
54     }
55 
testStandardResource()56     private static void testStandardResource() {
57         test(ALERT.toDisplayString(Locale.ENGLISH), "alert");
58         test(ALERT.toDisplayString(Locale.JAPAN), "\u30a2\u30e9\u30fc\u30c8");
59         test(LABEL.toDisplayString(Locale.ENGLISH), "label");
60         test(LABEL.toDisplayString(Locale.JAPAN), "\u30e9\u30d9\u30eb");
61         test(PANEL.toDisplayString(Locale.ENGLISH), "panel");
62         test(PANEL.toDisplayString(Locale.JAPAN), "\u30D1\u30CD\u30EB");
63         test(MANAGES_DESCENDANTS.toDisplayString(Locale.ENGLISH),
64              "manages descendants");
65         test(MANAGES_DESCENDANTS.toDisplayString(Locale.JAPAN),
66              "\u5B50\u5B6B\u3092\u7BA1\u7406");
67     }
68 
test(final String actual, final String expected)69     private static void test(final String actual, final String expected) {
70         if (!actual.equals(expected)) {
71             System.err.println("Expected: " + expected);
72             System.err.println("Actual: " + actual);
73             throw new RuntimeException("Wrong text");
74         }
75     }
76 }
77