2
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*/
|
|
23 |
/*
|
|
24 |
@test
|
|
25 |
@summary test Bug 4083270
|
|
26 |
@run main Bug4083270Test
|
|
27 |
@bug 4083270
|
|
28 |
*/
|
|
29 |
/*
|
|
30 |
*
|
|
31 |
*
|
|
32 |
* (C) Copyright IBM Corp. 1999 - All Rights Reserved
|
|
33 |
*
|
|
34 |
* The original version of this source code and documentation is
|
|
35 |
* copyrighted and owned by IBM. These materials are provided
|
|
36 |
* under terms of a License Agreement between IBM and Sun.
|
|
37 |
* This technology is protected by multiple US and International
|
|
38 |
* patents. This notice and attribution to IBM may not be removed.
|
|
39 |
*
|
|
40 |
*/
|
|
41 |
|
|
42 |
import java.util.*;
|
|
43 |
|
|
44 |
/*
|
|
45 |
* Bug: ResourceBundle.geBundle does not check for subclass of ResourceBundle.
|
|
46 |
* This test tries to load a properties file that has a class file with the
|
|
47 |
* same name that isn't a subclass of ResourceBundle. If the properties
|
|
48 |
* file is found, that means that getBundle ignored the class file because
|
|
49 |
* it wasn't a subclass of ResourceBundle.
|
|
50 |
*/
|
|
51 |
public class Bug4083270Test extends RBTestFmwk {
|
|
52 |
public static void main(String[] args) throws Exception {
|
|
53 |
new Bug4083270Test(true).run(args);
|
|
54 |
}
|
|
55 |
|
|
56 |
public Bug4083270Test(boolean dummy) {
|
|
57 |
}
|
|
58 |
|
|
59 |
public Bug4083270Test() throws Exception {
|
|
60 |
//If we get here, it means getBundle tried to instantiate this
|
|
61 |
//class. It shouldn't since this class does not subclass
|
|
62 |
//ResourceBundle.
|
|
63 |
errln("ResourceBundle loaded a non-ResourceBundle class");
|
|
64 |
}
|
|
65 |
|
|
66 |
public void testRecursiveResourceLoads() throws Exception {
|
|
67 |
final String className = getClass().getName();
|
|
68 |
try {
|
|
69 |
ResourceBundle bundle = ResourceBundle.getBundle(className, Locale.getDefault());
|
|
70 |
if (bundle == null) {
|
|
71 |
errln("ResourceBundle did not find properties file");
|
|
72 |
} else if (!(bundle instanceof PropertyResourceBundle)) {
|
|
73 |
errln("ResourceBundle loaded a non-ResourceBundle class");
|
|
74 |
}
|
|
75 |
} catch (MissingResourceException e) {
|
|
76 |
errln("ResourceBundle threw a MissingResourceException");
|
|
77 |
}
|
|
78 |
}
|
|
79 |
}
|