Path: blob/master/test/jdk/java/util/ResourceBundle/Bug4083270Test.java
41149 views
/*1* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22/*23@test24@summary test Bug 408327025@run main Bug4083270Test26@bug 408327027*/28/*29*30*31* (C) Copyright IBM Corp. 1999 - All Rights Reserved32*33* The original version of this source code and documentation is34* copyrighted and owned by IBM. These materials are provided35* under terms of a License Agreement between IBM and Sun.36* This technology is protected by multiple US and International37* patents. This notice and attribution to IBM may not be removed.38*39*/4041import java.util.*;4243/*44* Bug: ResourceBundle.geBundle does not check for subclass of ResourceBundle.45* This test tries to load a properties file that has a class file with the46* same name that isn't a subclass of ResourceBundle. If the properties47* file is found, that means that getBundle ignored the class file because48* it wasn't a subclass of ResourceBundle.49*/50public class Bug4083270Test extends RBTestFmwk {51public static void main(String[] args) throws Exception {52new Bug4083270Test(true).run(args);53}5455public Bug4083270Test(boolean dummy) {56}5758public Bug4083270Test() throws Exception {59//If we get here, it means getBundle tried to instantiate this60//class. It shouldn't since this class does not subclass61//ResourceBundle.62errln("ResourceBundle loaded a non-ResourceBundle class");63}6465public void testRecursiveResourceLoads() throws Exception {66final String className = getClass().getName();67try {68ResourceBundle bundle = ResourceBundle.getBundle(className, Locale.getDefault());69if (bundle == null) {70errln("ResourceBundle did not find properties file");71} else if (!(bundle instanceof PropertyResourceBundle)) {72errln("ResourceBundle loaded a non-ResourceBundle class");73}74} catch (MissingResourceException e) {75errln("ResourceBundle threw a MissingResourceException");76}77}78}798081