jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java
author dfuchs
Wed, 27 Apr 2016 18:04:16 +0200
changeset 37672 03684934dc09
parent 35315 67dcc46f8241
child 42338 a60f280f803c
permissions -rw-r--r--
8148568: LoggerFinder.getLogger and LoggerFinder.getLocalizedLogger should take a Module argument instead of a Class. Summary: Changes System.LoggerFinder methods to take a Module argument instead of a Class. Reviewed-by: mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34428
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
     1
/*
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
     4
 *
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
     7
 * published by the Free Software Foundation.
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
     8
 *
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    13
 * accompanied this code).
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    14
 *
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    18
 *
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    21
 * questions.
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    22
 */
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    23
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    24
import java.io.PrintStream;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    25
import java.lang.System.Logger;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    26
import java.lang.System.Logger.Level;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    27
import java.util.ArrayList;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    28
import java.util.concurrent.atomic.AtomicBoolean;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    29
import java.util.Enumeration;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    30
import java.util.List;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    31
import java.util.ResourceBundle;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    32
import java.util.Set;
37672
03684934dc09 8148568: LoggerFinder.getLogger and LoggerFinder.getLocalizedLogger should take a Module argument instead of a Class.
dfuchs
parents: 35315
diff changeset
    33
import java.lang.reflect.Module;
34428
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    34
import jdk.internal.logger.BootstrapLogger;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    35
import jdk.internal.logger.LazyLoggers;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    36
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    37
/*
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    38
 * @test
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    39
 * @bug     8144460 8144214
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    40
 * @summary Cover the logXX and LogEvent.valueOf APIs of BootstrapLogger
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    41
 *          and logXX APIs of SimpleConsoleLogger.
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    42
 * @modules java.base/jdk.internal.logger
35315
67dcc46f8241 8148147: Sync up @modules from jigsaw/jake
alanb
parents: 34428
diff changeset
    43
 *          java.base/sun.util.logging
34428
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    44
 * @build BootstrapLoggerUtils LogStream
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    45
 * @run main/othervm BootstrapLoggerAPIsTest
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    46
 */
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    47
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    48
public class BootstrapLoggerAPIsTest {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    49
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    50
    private static final LogStream ERR = new LogStream();
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    51
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    52
    public static void main(String[] args) throws Exception {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    53
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    54
        final ContentManager MGR = new ContentManager();
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    55
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    56
        // private reflection hook that allows us to simulate a non booted VM
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    57
        final AtomicBoolean VM_BOOTED = new AtomicBoolean(false);
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    58
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    59
        BootstrapLoggerUtils.setBootedHook(() -> VM_BOOTED.get());
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    60
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    61
        // We replace System.err to check the messages that have been logged
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    62
        // by the JUL ConsoleHandler and default SimpleConsoleLogger
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    63
        // implementaion
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    64
        System.setErr(new PrintStream(ERR));
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    65
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    66
        VM_BOOTED.getAndSet(false);
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    67
        if (BootstrapLogger.isBooted()) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    68
            throw new RuntimeException("VM should not be booted!");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    69
        }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    70
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    71
        final Logger LOGGER =
37672
03684934dc09 8148568: LoggerFinder.getLogger and LoggerFinder.getLocalizedLogger should take a Module argument instead of a Class.
dfuchs
parents: 35315
diff changeset
    72
                LazyLoggers.getLogger("foo.bar", Thread.class.getModule());
34428
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    73
        final sun.util.logging.PlatformLogger.Level PLATFORM_LEVEL =
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    74
                sun.util.logging.PlatformLogger.Level.SEVERE;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    75
        final MyResources BUNDLE = new MyResources();
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    76
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    77
        /*
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    78
         * Test logXX APIs for interface java.lang.System.Logger. Log content
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    79
         * before VM is booted should be retained. Log content after VM was
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    80
         * booted should be flushed instantly. VM is not booted in first round
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    81
         * of loop, VM is booted in second round of loop.
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    82
         */
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    83
        for (int i = 0; i < 2; i++) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    84
            boolean booted = BootstrapLogger.isBooted();
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    85
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    86
            // make sure there is no [remaining] content in the LogStream.
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    87
            MGR.failLog("xyz", "throwable #", "MyClass_#", "MyMethod_#");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    88
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    89
            /*
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    90
             * test logXX APIs for interface java.lang.System.Logger.
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    91
             */
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    92
            // void log(java.lang.System$Logger$Level,java.util.ResourceBundle,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    93
            //          java.lang.String,java.lang.Throwable)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    94
            LOGGER.log(Level.ERROR, BUNDLE, "abc #0", new RuntimeException("throwable #0"));
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    95
            MGR.checkLog(booted, "xyz #0", "throwable #0");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    96
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    97
            // void log(java.lang.System$Logger$Level,java.util.ResourceBundle,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    98
            //          java.lang.String,java.lang.Object[])
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
    99
            LOGGER.log(Level.ERROR, BUNDLE, "abc #1");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   100
            MGR.checkLog(booted, "xyz #1");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   101
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   102
            // void log(java.lang.System$Logger$Level,java.lang.String,java.lang.Object[])
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   103
            LOGGER.log(Level.ERROR, BUNDLE, "abc {0}", "#2");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   104
            MGR.checkLog(booted, "xyz #2");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   105
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   106
            // void log(java.lang.System$Logger$Level,java.lang.String,java.lang.Throwable)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   107
            LOGGER.log(Level.ERROR, "xyz #3", new RuntimeException("throwable #3"));
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   108
            MGR.checkLog(booted, "xyz #3", "throwable #3");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   109
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   110
            // void log(java.lang.System$Logger$Level,java.util.function.Supplier)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   111
            LOGGER.log(Level.ERROR, () -> "xyz #4");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   112
            MGR.checkLog(booted, "xyz #4");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   113
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   114
            // void log(java.lang.System$Logger$Level,java.lang.Object)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   115
            LOGGER.log(Level.ERROR, new MyObject("xyz #5"));
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   116
            MGR.checkLog(booted, "xyz #5");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   117
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   118
            // void log(java.lang.System$Logger$Level,java.util.function.Supplier,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   119
            //          java.lang.Throwable)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   120
            LOGGER.log(Level.ERROR, () -> "xyz #6", new RuntimeException("throwable #6"));
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   121
            MGR.checkLog(booted, "xyz #6", "throwable #6");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   122
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   123
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   124
            /*
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   125
             * test logXX APIs for interface
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   126
             * sun.util.logging.PlatformLogger.Bridge.
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   127
             */
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   128
            sun.util.logging.PlatformLogger.Bridge bridge =
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   129
                    (sun.util.logging.PlatformLogger.Bridge) LOGGER;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   130
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   131
            // void log(sun.util.logging.PlatformLogger$Level,java.lang.String)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   132
            bridge.log(PLATFORM_LEVEL, "xyz #7");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   133
            MGR.checkLog(booted, "xyz #7");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   134
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   135
            // void log(sun.util.logging.PlatformLogger$Level,java.lang.String,java.lang.Throwable)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   136
            bridge.log(PLATFORM_LEVEL, "xyz #8", new RuntimeException("throwable #8"));
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   137
            MGR.checkLog(booted, "xyz #8", "throwable #8");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   138
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   139
            // void log(sun.util.logging.PlatformLogger$Level,java.lang.String,java.lang.Object[])
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   140
            bridge.log(PLATFORM_LEVEL, "xyz {0}", "#9");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   141
            MGR.checkLog(booted, "xyz #9");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   142
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   143
            // void log(sun.util.logging.PlatformLogger$Level,java.util.function.Supplier)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   144
            bridge.log(PLATFORM_LEVEL, () -> "xyz #10");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   145
            MGR.checkLog(booted, "xyz #10");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   146
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   147
            // void log(sun.util.logging.PlatformLogger$Level,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   148
            //        java.lang.Throwable,java.util.function.Supplier)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   149
            bridge.log(PLATFORM_LEVEL, new RuntimeException("throwable #11"), () -> "xyz #11");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   150
            MGR.checkLog(booted, "xyz #11", "throwable #11");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   151
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   152
            // void logp(sun.util.logging.PlatformLogger$Level,java.lang.String,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   153
            //          java.lang.String,java.lang.String)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   154
            bridge.logp(PLATFORM_LEVEL, "MyClass_#12", "MyMethod_#12", "xyz #12");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   155
            MGR.checkLog(booted, "xyz #12", "MyClass_#12", "MyMethod_#12");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   156
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   157
            // void logp(sun.util.logging.PlatformLogger$Level,java.lang.String,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   158
            //          java.lang.String,java.util.function.Supplier)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   159
            bridge.logp(PLATFORM_LEVEL, "MyClass_#13", "MyMethod_#13", () -> "xyz #13");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   160
            MGR.checkLog(booted, "xyz #13", "MyClass_#13", "MyMethod_#13");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   161
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   162
            // void logp(sun.util.logging.PlatformLogger$Level,java.lang.String,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   163
            //          java.lang.String,java.lang.String,java.lang.Object[])
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   164
            bridge.logp(PLATFORM_LEVEL, "MyClass_#14", "MyMethod_#14", "xyz {0}", "#14");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   165
            MGR.checkLog(booted, "xyz #14", "MyClass_#14", "MyMethod_#14");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   166
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   167
            // void logp(sun.util.logging.PlatformLogger$Level,java.lang.String,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   168
            //          java.lang.String,java.lang.String,java.lang.Throwable)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   169
            bridge.logp(PLATFORM_LEVEL, "MyClass_#15", "MyMethod_#15",
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   170
                    "xyz #15", new RuntimeException("throwable #15"));
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   171
            MGR.checkLog(booted, "xyz #15", "throwable #15", "MyClass_#15", "MyMethod_#15");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   172
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   173
            // void logp(sun.util.logging.PlatformLogger$Level,java.lang.String,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   174
            //          java.lang.String,java.lang.Throwable,java.util.function.Supplier)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   175
            bridge.logp(PLATFORM_LEVEL, "MyClass_#16", "MyMethod_#16",
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   176
                    new RuntimeException("throwable #16"), () -> "xyz #16");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   177
            MGR.checkLog(booted, "xyz #16", "throwable #16", "MyClass_#16", "MyMethod_#16");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   178
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   179
            // void logrb(sun.util.logging.PlatformLogger$Level,java.lang.String,java.lang.String,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   180
            //          java.util.ResourceBundle,java.lang.String,java.lang.Object[])
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   181
            bridge.logrb(PLATFORM_LEVEL, "MyClass_#17", "MyMethod_#17",
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   182
                    BUNDLE, "abc {0}", "#17");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   183
            MGR.checkLog(booted, "xyz #17", "MyClass_#17", "MyMethod_#17");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   184
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   185
            // void logrb(sun.util.logging.PlatformLogger$Level,java.lang.String,java.lang.String,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   186
            //          java.util.ResourceBundle,java.lang.String,java.lang.Throwable)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   187
            bridge.logrb(PLATFORM_LEVEL, "MyClass_#18", "MyMethod_#18",
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   188
                    BUNDLE, "abc #18", new RuntimeException("throwable #18"));
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   189
            MGR.checkLog(booted, "xyz #18", "throwable #18", "MyClass_#18", "MyMethod_#18");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   190
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   191
            // void logrb(sun.util.logging.PlatformLogger$Level,java.util.ResourceBundle,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   192
            //          java.lang.String,java.lang.Object[])
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   193
            bridge.logrb(PLATFORM_LEVEL, BUNDLE, "abc {0}", "#19");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   194
            MGR.checkLog(booted, "xyz #19");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   195
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   196
            // void logrb(sun.util.logging.PlatformLogger$Level,java.util.ResourceBundle,
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   197
            //          java.lang.String,java.lang.Throwable)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   198
            bridge.logrb(PLATFORM_LEVEL, BUNDLE, "abc #20",
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   199
                        new RuntimeException("throwable #20"));
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   200
            MGR.checkLog(booted, "xyz #20", "throwable #20");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   201
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   202
            /*
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   203
             * retained log content should be flushed after VM is booted.
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   204
             */
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   205
            if (!booted) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   206
                VM_BOOTED.getAndSet(true);
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   207
                // trigger the flush, make sure to call LOGGER.log(...)
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   208
                // after VM_BOOTED.getAndSet(true) and before MGR.assertCachedLog()
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   209
                LOGGER.log(Level.ERROR, "VM was just booted! This log should flush the cached logs.");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   210
                MGR.assertCachedLog();
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   211
            }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   212
        }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   213
    }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   214
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   215
    private static class ContentManager {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   216
        final List<String[]> cached = new ArrayList<String[]>();
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   217
        String[] last;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   218
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   219
        public void cache() {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   220
            cached.add(last);
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   221
        }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   222
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   223
        public ContentManager failLog(String... nonexistent) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   224
            last = nonexistent;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   225
            for (String c : nonexistent) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   226
                if (ERR.drain().contains(c)) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   227
                    throw new RuntimeException("Content \"" + nonexistent
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   228
                            + "\" should not exist in the log!");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   229
                }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   230
            }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   231
            return this;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   232
        }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   233
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   234
        public void assertLog(String... logs) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   235
            String log = ERR.drain();
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   236
            for (String str : logs) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   237
                if (!log.contains(str)) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   238
                    throw new RuntimeException("Content \"" + str + "\" does not exist in the log!");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   239
                }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   240
            }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   241
        }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   242
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   243
        public void checkLog(boolean booted, String... logs) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   244
            if (!booted) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   245
                failLog(logs).cache();
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   246
            } else {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   247
                assertLog(logs);
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   248
            }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   249
        }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   250
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   251
        public void assertCachedLog() {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   252
            String log = ERR.drain();
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   253
            for (String[] arr : cached) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   254
                for (String c : arr) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   255
                    if (!log.contains(c)) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   256
                        throw new RuntimeException("Content \"" + c + "\" does not exist in the log!");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   257
                    }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   258
                }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   259
            }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   260
        }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   261
    }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   262
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   263
    private static class MyObject {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   264
        String str;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   265
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   266
        public MyObject(String str) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   267
            this.str = str;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   268
        }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   269
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   270
        public String toString() {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   271
            return str;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   272
        }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   273
    }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   274
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   275
    private static class MyResources extends ResourceBundle {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   276
        public Object handleGetObject(String key) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   277
            if (key.contains("abc #") || key.contains("abc {")) {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   278
                return key.replaceAll("abc ", "xyz ");
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   279
            }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   280
            return null;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   281
        }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   282
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   283
        public Enumeration<String> getKeys() {
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   284
            return null;
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   285
        }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   286
    }
39f1caf048c3 8144460: Improve the code coverage for BootstrapLogger and SimpleConsoleLogger APIs and verify bug fix JDK-8144214
mli
parents:
diff changeset
   287
}