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