1 /* 2 * Copyright (c) 2013, 2016, 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 import java.io.*; 25 import java.util.*; 26 27 import java.util.logging.*; 28 import sun.util.logging.PlatformLogger; 29 30 /* 31 * @test 32 * @bug 8005615 8006104 33 * @summary Add loggers to custom log manager 34 * 35 * @modules java.base/sun.util.logging 36 * java.logging 37 * @compile -XDignore.symbol.file CustomLogManagerTest.java CustomLogManager.java 38 * @run main/othervm -Djava.util.logging.manager=CustomLogManager CustomLogManagerTest 39 */ 40 public class CustomLogManagerTest { 41 private static final String RESOURCE_BUNDLE = "sun.util.logging.resources.logging"; main(String[] args)42 public static void main(String[] args) { 43 String mgr = System.getProperty("java.util.logging.manager"); 44 if (!mgr.equals("CustomLogManager")) { 45 throw new RuntimeException("java.util.logging.manager not set"); 46 } 47 48 Logger.getLogger(CustomLogManagerTest.class.getName()); 49 Logger.getLogger("org.foo.Foo"); 50 Logger.getLogger("org.foo.bar.Foo", RESOURCE_BUNDLE); 51 // platform logger will be set with the default system resource bundle 52 PlatformLogger.getLogger("org.openjdk.core.logger"); 53 54 if (LogManager.getLogManager() != CustomLogManager.INSTANCE) { 55 throw new RuntimeException(LogManager.getLogManager() + " not CustomLogManager"); 56 } 57 58 CustomLogManager.checkLogger(CustomLogManagerTest.class.getName()); 59 CustomLogManager.checkLogger("org.foo.Foo"); 60 CustomLogManager.checkLogger("org.foo.bar.Foo", RESOURCE_BUNDLE); 61 CustomLogManager.checkLogger(Logger.GLOBAL_LOGGER_NAME); 62 CustomLogManager.checkLogger(""); 63 CustomLogManager.checkLogger("org.openjdk.core.logger", RESOURCE_BUNDLE); 64 } 65 } 66