jdk/test/java/util/ResourceBundle/Bug4083270Test.java
changeset 2 90ce3da70b43
child 5285 7a74a8db7ef3
equal deleted inserted replaced
0:fd16c54261b3 2:90ce3da70b43
       
     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  * Portions Copyright 2007 by Sun Microsystems, Inc.,
       
    35  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
       
    36  * All rights reserved.
       
    37  *
       
    38  * This software is the confidential and proprietary information
       
    39  * of Sun Microsystems, Inc. ("Confidential Information").  You
       
    40  * shall not disclose such Confidential Information and shall use
       
    41  * it only in accordance with the terms of the license agreement
       
    42  * you entered into with Sun.
       
    43  *
       
    44  * The original version of this source code and documentation is
       
    45  * copyrighted and owned by IBM. These materials are provided
       
    46  * under terms of a License Agreement between IBM and Sun.
       
    47  * This technology is protected by multiple US and International
       
    48  * patents. This notice and attribution to IBM may not be removed.
       
    49  *
       
    50  */
       
    51 
       
    52 import java.util.*;
       
    53 
       
    54 /*
       
    55  * Bug: ResourceBundle.geBundle does not check for subclass of ResourceBundle.
       
    56  * This test tries to load a properties file that has a class file with the
       
    57  * same name that isn't a subclass of ResourceBundle.  If the properties
       
    58  * file is found, that means that getBundle ignored the class file because
       
    59  * it wasn't a subclass of ResourceBundle.
       
    60  */
       
    61 public class Bug4083270Test extends RBTestFmwk {
       
    62     public static void main(String[] args) throws Exception {
       
    63         new Bug4083270Test(true).run(args);
       
    64     }
       
    65 
       
    66     public Bug4083270Test(boolean dummy) {
       
    67     }
       
    68 
       
    69     public Bug4083270Test() throws Exception {
       
    70         //If we get here, it means getBundle tried to instantiate this
       
    71         //class.  It shouldn't since this class does not subclass
       
    72         //ResourceBundle.
       
    73         errln("ResourceBundle loaded a non-ResourceBundle class");
       
    74     }
       
    75 
       
    76     public void testRecursiveResourceLoads() throws Exception {
       
    77         final String className = getClass().getName();
       
    78         try {
       
    79             ResourceBundle bundle = ResourceBundle.getBundle(className, Locale.getDefault());
       
    80             if (bundle == null) {
       
    81                 errln("ResourceBundle did not find properties file");
       
    82             } else if (!(bundle instanceof PropertyResourceBundle)) {
       
    83                 errln("ResourceBundle loaded a non-ResourceBundle class");
       
    84             }
       
    85         } catch (MissingResourceException e) {
       
    86             errln("ResourceBundle threw a MissingResourceException");
       
    87         }
       
    88     }
       
    89 }