duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 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 | The fix for 4165815 has been backed out because of compatibility issues. |
| 25 | Disabled this test temporarily until a better fix is found by removing |
| 26 | the at-signs. |
| 27 | test |
| 28 | summary test Bug 4165815 |
| 29 | run main Bug4165815Test |
| 30 | bug 4165815 |
| 31 | */ |
| 32 | /* |
| 33 | * |
| 34 | * |
| 35 | * (C) Copyright IBM Corp. 1999 - All Rights Reserved |
| 36 | * |
| 37 | * Portions Copyright 2007 by Sun Microsystems, Inc., |
| 38 | * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. |
| 39 | * All rights reserved. |
| 40 | * |
| 41 | * This software is the confidential and proprietary information |
| 42 | * of Sun Microsystems, Inc. ("Confidential Information"). You |
| 43 | * shall not disclose such Confidential Information and shall use |
| 44 | * it only in accordance with the terms of the license agreement |
| 45 | * you entered into with Sun. |
| 46 | * |
| 47 | * The original version of this source code and documentation is |
| 48 | * copyrighted and owned by IBM. These materials are provided |
| 49 | * under terms of a License Agreement between IBM and Sun. |
| 50 | * This technology is protected by multiple US and International |
| 51 | * patents. This notice and attribution to IBM may not be removed. |
| 52 | * |
| 53 | */ |
| 54 | |
| 55 | import java.util.Locale; |
| 56 | import java.util.ResourceBundle; |
| 57 | import java.util.MissingResourceException; |
| 58 | |
| 59 | /** |
| 60 | * This is a regression test for the following bug: |
| 61 | * "If the path specified by the baseName argument to |
| 62 | * ResourceBundle.getBundle() begins with a leading slash, then the bundle |
| 63 | * is not found relative to the classpath. |
| 64 | * |
| 65 | * Clearly, the leading slash was inappropriate, however this did work |
| 66 | * previously (pre 1.2) and should continue to work in the same fashion." |
| 67 | * |
| 68 | * A Bundle base name should never contain a "/" and thus an |
| 69 | * IllegalArgumentException should be thrown. |
| 70 | */ |
| 71 | public class Bug4165815Test extends RBTestFmwk { |
| 72 | public static void main(String[] args) throws Exception { |
| 73 | new Bug4165815Test().run(args); |
| 74 | } |
| 75 | |
| 76 | private static final String bundleName = "/Bug4165815Bundle"; |
| 77 | public void testIt() throws Exception { |
| 78 | try { |
| 79 | ResourceBundle bundle = ResourceBundle.getBundle(bundleName, new Locale("en", "US")); |
| 80 | errln("ResourceBundle returned a bundle when it should not have."); |
| 81 | } catch (IllegalArgumentException e) { |
| 82 | //This is what we should get when the base name contains a "/" character. |
| 83 | } catch (MissingResourceException e) { |
| 84 | errln("ResourceBundle threw a MissingResourceException when it should have thrown an IllegalArgumentException."); |
| 85 | } |
| 86 | } |
| 87 | } |