1/*
2 * Copyright (c) 2007, 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    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 * The original version of this source code and documentation is
38 * copyrighted and owned by IBM. These materials are provided
39 * under terms of a License Agreement between IBM and Sun.
40 * This technology is protected by multiple US and International
41 * patents. This notice and attribution to IBM may not be removed.
42 *
43 */
44
45import java.util.Locale;
46import java.util.ResourceBundle;
47import java.util.MissingResourceException;
48
49/**
50 *  This is a regression test for the following bug:
51 *  "If the path specified by the baseName argument to
52 *  ResourceBundle.getBundle() begins with a leading slash, then the bundle
53 *  is not found relative to the classpath.
54 *
55 *  Clearly, the leading slash was inappropriate, however this did work
56 *  previously (pre 1.2) and should continue to work in the same fashion."
57 *
58 *  A Bundle base name should never contain a "/" and thus an
59 *  IllegalArgumentException should be thrown.
60 */
61public class Bug4165815Test extends RBTestFmwk {
62    public static void main(String[] args) throws Exception {
63        new Bug4165815Test().run(args);
64    }
65
66    private static final String bundleName = "/Bug4165815Bundle";
67    public void testIt() throws Exception {
68        try {
69            ResourceBundle bundle = ResourceBundle.getBundle(bundleName, new Locale("en", "US"));
70            errln("ResourceBundle returned a bundle when it should not have.");
71        } catch (IllegalArgumentException e) {
72            //This is what we should get when the base name contains a "/" character.
73        } catch (MissingResourceException e) {
74            errln("ResourceBundle threw a MissingResourceException when it should have thrown an IllegalArgumentException.");
75        }
76    }
77}
78