Path: blob/master/test/jdk/java/util/ResourceBundle/Bug4165815Test.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/*23The fix for 4165815 has been backed out because of compatibility issues.24Disabled this test temporarily until a better fix is found by removing25the at-signs.26test27summary test Bug 416581528run main Bug4165815Test29bug 416581530*/31/*32*33*34* (C) Copyright IBM Corp. 1999 - All Rights Reserved35*36* The original version of this source code and documentation is37* copyrighted and owned by IBM. These materials are provided38* under terms of a License Agreement between IBM and Sun.39* This technology is protected by multiple US and International40* patents. This notice and attribution to IBM may not be removed.41*42*/4344import java.util.Locale;45import java.util.ResourceBundle;46import java.util.MissingResourceException;4748/**49* This is a regression test for the following bug:50* "If the path specified by the baseName argument to51* ResourceBundle.getBundle() begins with a leading slash, then the bundle52* is not found relative to the classpath.53*54* Clearly, the leading slash was inappropriate, however this did work55* previously (pre 1.2) and should continue to work in the same fashion."56*57* A Bundle base name should never contain a "/" and thus an58* IllegalArgumentException should be thrown.59*/60public class Bug4165815Test extends RBTestFmwk {61public static void main(String[] args) throws Exception {62new Bug4165815Test().run(args);63}6465private static final String bundleName = "/Bug4165815Bundle";66public void testIt() throws Exception {67try {68ResourceBundle bundle = ResourceBundle.getBundle(bundleName, new Locale("en", "US"));69errln("ResourceBundle returned a bundle when it should not have.");70} catch (IllegalArgumentException e) {71//This is what we should get when the base name contains a "/" character.72} catch (MissingResourceException e) {73errln("ResourceBundle threw a MissingResourceException when it should have thrown an IllegalArgumentException.");74}75}76}777879