6435N/A * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 6435N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6435N/A * This code is free software; you can redistribute it and/or modify it 6435N/A * under the terms of the GNU General Public License version 2 only, as 6435N/A * published by the Free Software Foundation. 6435N/A * This code is distributed in the hope that it will be useful, but WITHOUT 6435N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6435N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6435N/A * version 2 for more details (a copy is included in the LICENSE file that 6435N/A * You should have received a copy of the GNU General Public License version 6435N/A * 2 along with this work; if not, write to the Free Software Foundation, 6435N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6435N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 6435N/A * or visit www.oracle.com if you need additional information or have any 6435N/A * @summary NPE when using Logger.getAnonymousLogger or 6435N/A * LogManager.getLogManager().getLogger 6435N/A// NOTE: We run in other VM in order to 1. switch security manager and 2. cause 6435N/A// LogManager class to be loaded anew. 6435N/A // Avoids the hassle of dealing with files and system props... 6435N/A // The bridge class initializes the logging system. 6435N/A // It stubs the applet context in order to simulate context changes. 6435N/A // When run - each of these two tests must be 6435N/A // run before any other tests and before each other. 6435N/A return "Test that when the LogManager class is" 6435N/A +
" loaded in an applet thread first," 6435N/A +
"\n all LoggerContexts are correctly initialized";
6435N/A return "Test that when the LogManager class is" 6435N/A +
" loaded in the main thread first," 6435N/A +
"\n all LoggerContexts are correctly initialized";
6435N/A return "Test that Logger.getAnonymousLogger()" 6435N/A +
" and new CustomAnonymousLogger() don't throw NPE";
6435N/A return "Test that Logger.getLogger(\"\")" 6435N/A +
" does not return null nor throws NPE";
6435N/A return "Test that LogManager.getLogManager().getLogger(\"\")" 6435N/A +
" does not return null nor throws NPE";
6435N/A return "Test that Logger.getLogger(Logger.GLOBAL_LOGGER_NAME)" 6435N/A +
" does not return null,\n and that" 6435N/A +
" new CustomAnonymousLogger(Logger.GLOBAL_LOGGER_NAME)" 6435N/A return "Test that LogManager.getLogManager().getLogger(Logger.GLOBAL_LOGGER_NAME)" 6435N/A +
"\n does not return null nor throws NPE";
6435N/A return "Test that manager.getLogger(Logger.GLOBAL_LOGGER_NAME)" 6435N/A +
" returns null\n when manager is not the default" 6435N/A +
" LogManager instance.\n" 6435N/A +
"Test adding a new logger named \"global\" in that" 6435N/A +
" non default instance.";
6435N/A case Seven:
return "Test that manager.getLogger(\"\")" 6435N/A +
" returns null\n when manager is not the default" 6435N/A +
" LogManager instance.\n" 6435N/A +
"Test adding a new logger named \"\" in that" 6435N/A +
" non default instance.";
6435N/A default:
return "Undefined";
6435N/A * @param args the command line arguments 6435N/A * This test is designed to test the behavior of additional LogManager instances. 6435N/A * It must be noted that if the security manager is off, then calling 6435N/A * Bridge.changeContext() has actually no effect - which explains why we have 6435N/A * some differences between the cases security manager on & security manager 6435N/A // this is not a supported configuration: 6435N/A // We are in an applet context with several log managers. 6435N/A // We however need to check our assumptions... 6435N/A // Applet context => root logger and global logger are not null. 6435N/A // root == LogManager.getLogManager().rootLogger 6435N/A // the LogManager's custom global logger added above... 6435N/A // the LogManager's custom global logger added above... 6435N/A // we will always get back the global logger. 6435N/A // this could be considered as a bug... 6435N/A * This test is designed to test the behavior of additional LogManager instances. 6435N/A * It must be noted that if the security manager is off, then calling 6435N/A * Bridge.changeContext() has actually no effect - which explains why we have 6435N/A * some differences between the cases security manager on & security manager 6435N/A // this is not a supported configuration: 6435N/A // We are in an applet context with several log managers. 6435N/A // We haowever need to check our assumptions... 6435N/A // Applet context => root logger and global logger are not null. 6435N/A // root == LogManager.getLogManager().rootLogger 6435N/A // we will always get back the global logger. 6435N/A // this could be considered as a bug... 6435N/A // we will always get back the default manager's root logger. 6435N/A // this could be considered as a bug...