Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/tools/native2ascii/resources/ImmutableResourceTest.java
38918 views
/*1* Copyright (c) 2005, 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*/2223/**24*25*26* This isn't the test case: ImmutableResourceTest.sh is.27* Refer to ImmutableResourceTest.sh when running this test.28*29* @bug 628757930* @summary SubClasses of ListResourceBundle should fix getContents()31*32* @author Tim Bell33*34*/35import java.util.ResourceBundle;3637public class ImmutableResourceTest {3839public static void main(String[] args) throws Exception {40/* Reach under the covers and get the message strings */41sun.tools.native2ascii.resources.MsgNative2ascii msgs =42new sun.tools.native2ascii.resources.MsgNative2ascii ();43Object [][] testData = msgs.getContents();4445/* Shred our copy of the message strings */46for (int ii = 0; ii < testData.length; ii++) {47testData[ii][0] = "T6287579";48testData[ii][1] = "yyy";49}5051/*52* Try to lookup the shredded key.53* If this is successful we have a problem.54*/55String ss = null;56try {57ss = msgs.getString("T6287579");58} catch (java.util.MissingResourceException mre) {59/*60* Ignore the expected MissingResourceException since key61* "T6287579" is not in the canonical MsgNative2ascii.62*/63}64if ("yyy".equals(ss)) {65throw new Exception ("SubClasses of ListResourceBundle should fix getContents()");66}67System.out.println("...Finished.");68}69}707172