6330N/A * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 6330N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6330N/A * This code is free software; you can redistribute it and/or modify it 6330N/A * under the terms of the GNU General Public License version 2 only, as 6330N/A * published by the Free Software Foundation. 6330N/A * This code is distributed in the hope that it will be useful, but WITHOUT 6330N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6330N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6330N/A * version 2 for more details (a copy is included in the LICENSE file that 6330N/A * You should have received a copy of the GNU General Public License version 6330N/A * 2 along with this work; if not, write to the Free Software Foundation, 6330N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6330N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 6330N/A * or visit www.oracle.com if you need additional information or have any 6330N/A * @summary Remove the stack search for a resource bundle Logger to use 6394N/A * @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp1 LoadItUp2 TwiceIndirectlyLoadABundle LoadItUp2Invoker 6397N/A * @run main/othervm -Djdk.logging.allowStackWalkSearch=true ResourceBundleSearchTest 6394N/A * This class tests various scenarios of loading resource bundles from 6394N/A * java.util.logging. Since jtreg uses the logging system, it is necessary to 6394N/A * run these tests using othervm mode to ensure no interference from logging 6330N/A // ensure we are using en as the default Locale so we can find the resource 6330N/A // Find out where we are running from so we can setup the URLClassLoader URL 6330N/A // Test 1 - can we find a Logger bundle from doing a stack search? 6397N/A // unless -Djdk.logging.allowStackWalkSearch=true is set 6330N/A // Test 2 - can we find a Logger bundle off of the Thread context class 6330N/A // loader? We should be able to. 6394N/A "2-testGetBundleFromTCCL");
6330N/A // Test 3 - Can we find a Logger bundle from the classpath? We should be 6394N/A // able to. We'll first check to make sure the setup is correct and 6394N/A // it actually is on the classpath before checking whether logging 6394N/A "3-testGetBundleFromSystemClassLoader");
6394N/A // Test 4 - we should be able to find a bundle from the caller's 6394N/A // classloader, but only one level up. 6394N/A "4-testGetBundleFromCallersClassLoader");
6394N/A // Test 5 - this ensures that getAnonymousLogger(String rbName) 6394N/A // can find the bundle from the caller's classloader 6394N/A // Test 6 - first call getLogger("myLogger"). 6394N/A // Then call getLogger("myLogger","bundleName") from a different ClassLoader 6394N/A // Make sure we find the bundle 6397N/A "6-testGetBundleFromSecondCallersClassLoader");
6330N/A // We only care about the messages if they were errors 6394N/A +
" was supposed to return true but did NOT!");
6394N/A +
" was supposed to return false but did NOT!");
6330N/A // This should fail. This was the old functionality to search up the 6394N/A // This should pass. This exercises getting the bundle using the 6394N/A // class loader of the caller (one level up) 6330N/A // This should succeed. We should be able to get the bundle from the 6330N/A // thread context class loader 6330N/A * @param String bundleClass 6330N/A * @param ClassLoader to use for search 6330N/A * @return true iff bundleClass is on system classpath 6330N/A // we need a new logger name every time we attempt to find a bundle via 6330N/A // the Logger.getLogger call, so we'll simply tack on an integer which 6330N/A // we increment each time this is called 6330N/A // this should succeed if the bundle is on the system classpath. 6330N/A msgs.
add(
"INFO: testGetBundleFromSystemClassLoader() did not find bundle " 6330N/A msgs.
add(
"INFO: testGetBundleFromSystemClassLoader() found the bundle " 6394N/A // This should pass. This exercises getting the bundle using the 6394N/A // class loader of the caller (one level up) when calling 6394N/A // Logger.getAnonymousLogger(String rbName) 6394N/A // This should pass. This exercises getting the bundle using the 6394N/A // class loader of the caller (one level up) 6330N/A // this should succeed if the bundle is on the system classpath.