test/jdk/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java
author kvn
Wed, 13 Dec 2017 11:59:55 -0800
changeset 48397 ead47ddf5844
parent 47216 71c04702a3d5
permissions -rw-r--r--
8191788: add jdk.internal.vm.compiler to --limit-modules if -Djvmci.Compiler=graal is in the command line Summary: skip tests which use --limit-modules when Graal is used as JIT compiler. Reviewed-by: alanb, mchung, dholmes, ccheung, dnsimon
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
     1
/*
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
     4
 *
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
     7
 * published by the Free Software Foundation.
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
     8
 *
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    13
 * accompanied this code).
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    14
 *
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    18
 *
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    21
 * questions.
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    22
 */
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    23
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    24
import java.io.ByteArrayOutputStream;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    25
import java.io.IOException;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    26
import java.io.OutputStream;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    27
import java.io.PrintStream;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    28
import java.lang.System.Logger;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    29
import java.lang.System.Logger.Level;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    30
import java.lang.System.LoggerFinder;
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
    31
import java.util.Collections;
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    32
import java.util.Enumeration;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    33
import java.util.Locale;
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
    34
import java.util.Map;
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    35
import java.util.Objects;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    36
import java.util.ResourceBundle;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    37
// Can't use testng because testng requires java.logging
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    38
//import org.testng.annotations.Test;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    39
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    40
/**
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    41
 * @test
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
    42
 * @bug 8177835 8179222
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    43
 * @summary Checks that the DefaultLoggerFinder and LoggingProviderImpl
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    44
 *          implementations of the System.LoggerFinder conform to the
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    45
 *          LoggerFinder specification, in particular with respect to
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    46
 *          throwing NullPointerException. The test uses --limit-module
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    47
 *          to force the selection of one or the other.
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    48
 * @author danielfuchs
48397
ead47ddf5844 8191788: add jdk.internal.vm.compiler to --limit-modules if -Djvmci.Compiler=graal is in the command line
kvn
parents: 47216
diff changeset
    49
 * @requires !vm.graal.enabled
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    50
 * @build LoggerFinderAPI
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    51
 * @run main/othervm --limit-modules java.base,java.logging
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    52
 *          -Djava.util.logging.SimpleFormatter.format=LOG-%4$s:-[%2$s]-%5$s%6$s%n
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    53
 *          LoggerFinderAPI
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    54
 * @run main/othervm -Djdk.system.logger.format=LOG-%4$s:-[%2$s]-%5$s%6$s%n
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    55
 *          --limit-modules java.base
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    56
 *          LoggerFinderAPI
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    57
 */
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    58
public class LoggerFinderAPI {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    59
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    60
    // Simplified log format string. No white space for main/othervm line
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    61
    static final String TEST_FORMAT = "LOG-%4$s:-[%2$s]-%5$s%6$s%n";
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    62
    static final String JDK_FORMAT_PROP_KEY = "jdk.system.logger.format";
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    63
    static final String JUL_FORMAT_PROP_KEY =
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    64
        "java.util.logging.SimpleFormatter.format";
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
    65
    static final String MESSAGE = "{0} with {1}: PASSED";
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
    66
    static final String LOCALIZED = "[localized] ";
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    67
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    68
    static class RecordStream extends OutputStream {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    69
        static final Object LOCK = new Object[0];
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    70
        final PrintStream out;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    71
        final PrintStream err;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    72
        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    73
        boolean record;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    74
        RecordStream(PrintStream out, PrintStream err) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    75
            this.out = out;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    76
            this.err = err;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    77
        }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    78
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    79
        @Override
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    80
        public void write(int i) throws IOException {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    81
            if (record) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    82
                bos.write(i);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    83
                out.write(i);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    84
            } else {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    85
                err.write(i);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    86
            }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    87
        }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    88
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    89
        void startRecording() {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    90
            out.flush();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    91
            err.flush();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    92
            bos.reset();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    93
            record = true;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    94
        }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    95
        byte[] stopRecording() {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    96
            out.flush();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    97
            err.flush();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    98
            record = false;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
    99
            return bos.toByteArray();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   100
        }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   101
    }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   102
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   103
    static final PrintStream ERR = System.err;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   104
    static final PrintStream OUT = System.out;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   105
    static final RecordStream LOG_STREAM = new RecordStream(OUT, ERR);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   106
    static {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   107
        Locale.setDefault(Locale.US);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   108
        PrintStream perr = new PrintStream(LOG_STREAM);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   109
        System.setErr(perr);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   110
    }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   111
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   112
    public static class MyResourceBundle extends ResourceBundle {
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   113
        final Map<String, String> map = Map.of(MESSAGE, LOCALIZED + MESSAGE);
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   114
        @Override
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   115
        protected Object handleGetObject(String string) {
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   116
            return map.get(string);
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   117
        }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   118
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   119
        @Override
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   120
        public Enumeration<String> getKeys() {
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   121
            return Collections.enumeration(map.keySet());
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   122
        }
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   123
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   124
    }
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   125
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   126
    public static class EmptyResourceBundle extends ResourceBundle {
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   127
        @Override
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   128
        protected Object handleGetObject(String string) {
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   129
            return null;
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   130
        }
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   131
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   132
        @Override
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   133
        public Enumeration<String> getKeys() {
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   134
            return Collections.emptyEnumeration();
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   135
        }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   136
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   137
    }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   138
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   139
    public static void main(String[] args) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   140
        // Set on the command line, to ensure that the test will fail if
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   141
        // the 'wrong' provider gets selected.
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   142
        // System.setProperty(JDK_FORMAT_PROP_KEY, TEST_FORMAT);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   143
        // System.setProperty(JUL_FORMAT_PROP_KEY, TEST_FORMAT);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   144
        LoggerFinder finder = System.LoggerFinder.getLoggerFinder();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   145
        System.out.println("LoggerFinder is " + finder.getClass().getName());
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   146
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   147
        LoggerFinderAPI apiTest = new LoggerFinderAPI();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   148
        for (Object[] params : getLoggerDataProvider()) {
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   149
            @SuppressWarnings("unchecked")
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   150
            Class<? extends Throwable> throwableClass  =
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   151
                    Throwable.class.getClass().cast(params[3]);
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   152
            apiTest.testGetLogger((String)params[0],
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   153
                                  (String)params[1],
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   154
                                  (Module)params[2],
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   155
                                  throwableClass);
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   156
        }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   157
        for (Object[] params : getLocalizedLoggerDataProvider()) {
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   158
            @SuppressWarnings("unchecked")
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   159
            Class<? extends Throwable> throwableClass =
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   160
                    Throwable.class.getClass().cast(params[4]);
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   161
            apiTest.testGetLocalizedLogger((String)params[0],
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   162
                                  (String)params[1],
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   163
                                  (ResourceBundle)params[2],
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   164
                                  (Module)params[3],
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   165
                                  throwableClass);
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   166
        }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   167
    }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   168
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   169
    //Can't use testng because testng requires java.logging
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   170
    //@Test(dataProvider = "testGetLoggerDataProvider")
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   171
    void testGetLogger(String desc, String name, Module mod, Class<? extends Throwable> thrown) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   172
        try {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   173
            LoggerFinder finder = System.LoggerFinder.getLoggerFinder();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   174
            Logger logger = finder.getLogger(name, mod);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   175
            if (thrown != null) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   176
                throw new AssertionError("Exception " + thrown.getName()
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   177
                        + " not thrown for "
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   178
                        + "LoggerFinder.getLogger"
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   179
                        + " with " + desc);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   180
            }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   181
            // Make sure we don't fail if tests are run in parallel
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   182
            synchronized(RecordStream.LOCK) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   183
                LOG_STREAM.startRecording();
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   184
                byte[] logged = null;
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   185
                try {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   186
                    logger.log(Level.INFO, "{0} with {1}: PASSED",
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   187
                               "LoggerFinder.getLogger",
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   188
                               desc);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   189
                } finally {
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   190
                    logged = LOG_STREAM.stopRecording();
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   191
                }
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   192
                check(logged, "testGetLogger", desc, null,
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   193
                      "LoggerFinder.getLogger");
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   194
            }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   195
        } catch (Throwable x) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   196
            if (thrown != null && thrown.isInstance(x)) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   197
                System.out.printf("Got expected exception for %s with %s: %s\n",
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   198
                        "LoggerFinder.getLogger", desc, String.valueOf(x));
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   199
            } else throw x;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   200
        }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   201
    }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   202
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   203
    //Can't use testng because testng requires java.logging
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   204
    //@Test(dataProvider = "getLocalizedLoggerDataProvider")
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   205
    void testGetLocalizedLogger(String desc, String name, ResourceBundle bundle,
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   206
                                Module mod, Class<? extends Throwable> thrown) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   207
        try {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   208
            LoggerFinder finder = System.LoggerFinder.getLoggerFinder();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   209
            Logger logger = finder.getLocalizedLogger(name, bundle, mod);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   210
            if (thrown != null) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   211
                throw new AssertionError("Exception " + thrown.getName()
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   212
                        + " not thrown for "
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   213
                        + "LoggerFinder.getLocalizedLogger"
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   214
                        + " with " + desc);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   215
            }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   216
            // Make sure we don't fail if tests are run in parallel
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   217
            synchronized(RecordStream.LOCK) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   218
                LOG_STREAM.startRecording();
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   219
                byte[] logged = null;
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   220
                try {
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   221
                    logger.log(Level.INFO, MESSAGE,
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   222
                              "LoggerFinder.getLocalizedLogger",
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   223
                              desc);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   224
                } finally {
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   225
                   logged = LOG_STREAM.stopRecording();
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   226
                }
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   227
                check(logged, "testGetLocalizedLogger", desc, bundle,
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   228
                      "LoggerFinder.getLocalizedLogger");
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   229
            }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   230
        } catch (Throwable x) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   231
            if (thrown != null && thrown.isInstance(x)) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   232
                System.out.printf("Got expected exception for %s with %s: %s\n",
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   233
                        "LoggerFinder.getLocalizedLogger", desc, String.valueOf(x));
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   234
            } else throw x;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   235
        }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   236
    }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   237
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   238
    private void check(byte[] logged, String test, String desc,
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   239
                       ResourceBundle bundle, String meth) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   240
        String msg = new String(logged);
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   241
        String localizedPrefix =
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   242
                ((bundle==null || bundle==EMPTY_BUNDLE)?"":LOCALIZED);
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   243
        String expected = String.format(TEST_FORMAT, null,
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   244
                "LoggerFinderAPI " + test, null, Level.INFO.name(),
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   245
                localizedPrefix + meth + " with " + desc + ": PASSED",
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   246
                "");
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   247
        if (!Objects.equals(msg, expected)) {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   248
            throw new AssertionError("Expected log message not found: "
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   249
                                     + "\n\texpected:  " + expected
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   250
                                     + "\n\tretrieved: " + msg);
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   251
        }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   252
    }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   253
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   254
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   255
    static final Module MODULE = LoggerFinderAPI.class.getModule();
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   256
    static final ResourceBundle BUNDLE = new MyResourceBundle();
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   257
    static final ResourceBundle EMPTY_BUNDLE = new EmptyResourceBundle();
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   258
    static final Object[][] GET_LOGGER = {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   259
        {"null name", null, MODULE , NullPointerException.class},
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   260
        {"null module", "foo", null, NullPointerException.class},
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   261
        {"null name and module", null, null, NullPointerException.class},
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   262
        {"non null name and module", "foo", MODULE, null},
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   263
    };
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   264
    static final Object[][] GET_LOCALIZED_LOGGER = {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   265
        {"null name", null, BUNDLE, MODULE , NullPointerException.class},
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   266
        {"null module", "foo", BUNDLE, null, NullPointerException.class},
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   267
        {"null name and module, non null bundle", null, BUNDLE, null, NullPointerException.class},
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   268
        {"non null name, module, and bundle", "foo", BUNDLE, MODULE, null},
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   269
        {"null name and bundle", null, null, MODULE , NullPointerException.class},
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   270
        {"null module and bundle", "foo", null, null, NullPointerException.class},
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   271
        {"null name and module and bundle", null, null, null, NullPointerException.class},
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   272
        {"non null name and module, null bundle", "foo", null, MODULE, null},
44911
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   273
        // tests that MissingResourceBundle is not propagated to the caller of
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   274
        // logger.log() if the key is not found in the resource bundle
7cfd28612947 8179222: SimpleConsoleLogger should protect against MissingResourceException
dfuchs
parents: 44545
diff changeset
   275
        {"non null name, module, and empty bundle", "foo", EMPTY_BUNDLE, MODULE, null},
44433
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   276
    };
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   277
    public static Object[][] getLoggerDataProvider() {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   278
        return GET_LOGGER;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   279
    }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   280
    public static Object[][] getLocalizedLoggerDataProvider() {
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   281
        return GET_LOCALIZED_LOGGER;
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   282
    }
82ca8259333d 8177835: System.LoggerFinder#getLogger or getLocalizedLogger does not throw NPE
dfuchs
parents:
diff changeset
   283
}