test/jdk/java/util/logging/SystemLoggerConfigTest.java
author mikael
Mon, 29 Jul 2019 09:59:04 -0700
changeset 57584 9d82a35b6ff7
parent 47216 71c04702a3d5
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39634
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
     1
/*
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
     4
 *
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
     7
 * published by the Free Software Foundation.
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
     8
 *
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    13
 * accompanied this code).
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    14
 *
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    18
 *
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    21
 * questions.
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    22
 */
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    23
import java.io.ByteArrayInputStream;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    24
import java.io.ByteArrayOutputStream;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    25
import java.io.IOException;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    26
import java.io.UncheckedIOException;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    27
import java.lang.ref.Reference;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    28
import java.security.Permission;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    29
import java.security.Policy;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    30
import java.security.ProtectionDomain;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    31
import java.util.ArrayList;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    32
import java.util.List;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    33
import java.util.Objects;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    34
import java.util.Properties;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    35
import java.util.concurrent.CopyOnWriteArrayList;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    36
import java.util.concurrent.atomic.AtomicLong;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    37
import java.util.logging.Handler;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    38
import java.util.logging.Level;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    39
import java.util.logging.LogManager;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    40
import java.util.logging.LogRecord;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    41
import java.util.logging.Logger;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    42
import java.util.stream.Collectors;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    43
import java.util.stream.Stream;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    44
import sun.util.logging.PlatformLogger;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    45
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    46
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    47
/**
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    48
 * @test
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    49
 * @bug     8159245
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    50
 * @summary Tests configuration of loggers.
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    51
 * @modules java.logging/sun.util.logging.internal java.base/sun.util.logging
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    52
 * @run  main/othervm SystemLoggerConfigTest NOSECURITY
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    53
 * @run  main/othervm SystemLoggerConfigTest WITHSECURITY
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    54
 *
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    55
 * @author danielfuchs
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    56
 */
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    57
public class SystemLoggerConfigTest {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    58
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    59
    static Logger createSystemLogger(String name) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    60
        return sun.util.logging.internal.LoggingProviderImpl.getLogManagerAccess()
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    61
                .demandLoggerFor(LogManager.getLogManager(), name,
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    62
                                 Thread.class.getModule());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    63
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    64
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    65
    static PlatformLogger createPlatformLogger(String name) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    66
        return PlatformLogger.getLogger(name);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    67
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    68
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    69
    private static void assertFalse(boolean value, String msg) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    70
        assertEquals(false, value, msg);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    71
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    72
    private static void assertEquals(boolean expected, boolean actual, String msg) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    73
        if (expected != actual) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    74
            throw new AssertionError(msg+": expected: " + expected + " actual: " + actual);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    75
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    76
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    77
    private static void assertEquals(int expected, int actual, String msg) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    78
        if (expected != actual) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    79
            throw new AssertionError(msg+": expected: " + expected + " actual: " + actual);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    80
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    81
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    82
    private static void assertEquals(long expected, long actual, String msg) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    83
        if (expected != actual) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    84
            throw new AssertionError(msg+": expected: " + expected + " actual: " + actual);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    85
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    86
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    87
    private static void assertEquals(Object expected, Object actual, String msg) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    88
        if (!Objects.equals(expected, actual)) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    89
            throw new AssertionError(msg+": expected: " + expected + " actual: " + actual);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    90
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    91
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    92
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    93
    static class TestHandler extends Handler {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    94
        private final List<LogRecord> records = new CopyOnWriteArrayList<>();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    95
        public TestHandler() {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    96
            super();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    97
            setLevel(Level.ALL);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    98
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
    99
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   100
        @Override
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   101
        public void publish(LogRecord lr) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   102
            records.add(lr);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   103
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   104
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   105
        public List<LogRecord> drain() {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   106
            List<LogRecord> list = new ArrayList<>(records);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   107
            records.clear();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   108
            return list;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   109
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   110
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   111
        public void close() {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   112
            records.clear();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   113
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   114
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   115
        public void flush() {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   116
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   117
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   118
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   119
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   120
    public static class TestHandler1 extends TestHandler {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   121
        final static AtomicLong COUNT = new AtomicLong();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   122
        public TestHandler1() {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   123
            COUNT.incrementAndGet();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   124
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   125
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   126
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   127
    public static class TestHandler2 extends TestHandler {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   128
        final static AtomicLong COUNT = new AtomicLong();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   129
        public TestHandler2() {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   130
            COUNT.incrementAndGet();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   131
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   132
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   133
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   134
    static enum TestCase { WITHSECURITY, NOSECURITY }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   135
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   136
    public static void main(String[] args) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   137
        if (args == null || args.length == 0) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   138
            args = Stream.of(TestCase.values())
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   139
                    .map(String::valueOf)
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   140
                    .collect(Collectors.toList())
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   141
                    .toArray(new String[0]);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   142
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   143
        Stream.of(args)
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   144
              .map(TestCase::valueOf)
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   145
              .forEach(SystemLoggerConfigTest::launch);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   146
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   147
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   148
    public static void launch(TestCase test) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   149
        switch(test) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   150
            case WITHSECURITY:
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   151
                Policy.setPolicy(new Policy() {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   152
                    @Override
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   153
                    public boolean implies(ProtectionDomain domain, Permission permission) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   154
                        return true;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   155
                    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   156
                });
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   157
                System.setSecurityManager(new SecurityManager());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   158
                break;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   159
            case NOSECURITY:
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   160
                break;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   161
            default:
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   162
                throw new InternalError("Unexpected enum: " + test);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   163
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   164
        try {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   165
            test(test.name(), ".1", ".child");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   166
            test(test.name(), ".2", "");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   167
            testUpdateConfiguration(test.name(), ".3");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   168
            testSetPlatformLevel(test.name(), ".4");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   169
        } catch (IOException io) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   170
            throw new UncheckedIOException(io);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   171
        }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   172
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   173
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   174
    public static void test(String name, String step, String ext)
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   175
            throws IOException {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   176
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   177
        System.out.println("\n*** Testing " + name + step + ext);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   178
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   179
        final String systemName1a = "system.logger.one.a." + name + step + ext;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   180
        final String systemName1b = "system.logger.one.b." + name + step + ext;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   181
        final String appName1a = "system.logger.one.a." + name + step;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   182
        final String appName1b = "system.logger.one.b." + name + step;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   183
        final String msg1a = "logger name: " + systemName1a;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   184
        final String msg1b = "logger name: " + systemName1b;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   185
        final String systemName2 = "system.logger.two." + name + step + ext;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   186
        final String appName2 = "system.logger.two." + name + step;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   187
        final String msg2 = "logger name: " + systemName2;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   188
        final String systemName3 = "system.logger.three." + name + step + ext;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   189
        final String appName3 = "system.logger.three." + name + step;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   190
        final String msg3 = "logger name: " + systemName3;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   191
        List<LogRecord> records;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   192
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   193
        System.out.println("\n[Case #1] Creating platform logger: " + systemName1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   194
        PlatformLogger system1a = createPlatformLogger(systemName1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   195
        System.out.println("    Creating platform logger: " + systemName1b);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   196
        PlatformLogger system1b = createPlatformLogger(systemName1b);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   197
        System.out.println("    Adding handler on root logger...");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   198
        TestHandler test1 = new TestHandler();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   199
        Logger.getLogger("").addHandler(test1);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   200
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   201
        System.out.println("    Creating and configuring app logger: " + appName1a
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   202
                + ", " + appName1b);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   203
        Logger app1a = Logger.getLogger(appName1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   204
        app1a.setLevel(Level.INFO);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   205
        Logger app1b = Logger.getLogger(appName1b);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   206
        app1b.setLevel(Level.INFO);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   207
        assertFalse(system1a.isLoggable(PlatformLogger.Level.FINEST),
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   208
                "Unexpected level for " + system1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   209
        System.out.println("    Configuring root logger...");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   210
        Logger.getLogger("").setLevel(Level.FINEST);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   211
        System.out.println("    Logging through system logger: " + systemName1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   212
        system1a.finest(msg1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   213
        Reference.reachabilityFence(app1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   214
        records = test1.drain();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   215
        assertEquals(0, records.size(), "Unexpected size for " + records.toString());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   216
        System.out.println("    Logging through system logger: " + systemName1b);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   217
        system1b.finest(msg1b);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   218
        Reference.reachabilityFence(app1b);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   219
        records = test1.drain();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   220
        assertEquals(0, records.size(), "Unexpected size for " + records.toString());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   221
        Logger.getLogger("system.logger.one.a").finest("system.logger.one.a");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   222
        records = test1.drain();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   223
        assertEquals("system.logger.one.a", records.get(0).getMessage(), "Unexpected message: ");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   224
        Logger.getLogger("").setLevel(Level.INFO);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   225
        Logger.getLogger("system.logger.one.a").finest("system.logger.one.a");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   226
        records = test1.drain();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   227
        assertEquals(0, records.size(), "Unexpected size for " + records.toString());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   228
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   229
        Reference.reachabilityFence(system1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   230
        Reference.reachabilityFence(system1b);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   231
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   232
        System.out.println("\n[Case #2] Creating system logger: " + systemName2);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   233
        Logger system2 = createSystemLogger(systemName2);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   234
        System.out.println("    Creating app logger: " + appName2);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   235
        Logger app2 = Logger.getLogger(appName2);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   236
        System.out.println("    Configuring app logger...");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   237
        TestHandler test2 = new TestHandler();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   238
        app2.setLevel(Level.ALL);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   239
        app2.setUseParentHandlers(false);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   240
        app2.addHandler(test2);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   241
        System.out.println("    Logging through system logger: " + systemName2);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   242
        system2.finest(msg2);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   243
        records = test2.drain();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   244
        assertEquals(1, records.size(), "Unexpected size for " + records.toString());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   245
        assertEquals(msg2, records.get(0).getMessage(), "Unexpected message: ");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   246
        records = test1.drain();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   247
        assertEquals(0, records.size(), "Unexpected size for " + records.toString());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   248
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   249
        Reference.reachabilityFence(app2);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   250
        Reference.reachabilityFence(system2);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   251
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   252
        System.out.println("\n[Case #3] Creating app logger: " + appName3);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   253
        Logger app3 = Logger.getLogger(appName3);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   254
        System.out.println("    Configuring app logger...");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   255
        TestHandler test3 = new TestHandler();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   256
        app3.setLevel(Level.ALL);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   257
        app3.setUseParentHandlers(false);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   258
        app3.addHandler(test3);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   259
        System.out.println("    Creating system logger: " + systemName3);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   260
        Logger system3 = createSystemLogger(systemName3);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   261
        System.out.println("    Logging through system logger: " + systemName3);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   262
        system3.finest(msg3);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   263
        records = test3.drain();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   264
        assertEquals(1, records.size(), "Unexpected size for " + records.toString());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   265
        assertEquals(msg3, records.get(0).getMessage(), "Unexpected message: ");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   266
        records = test1.drain();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   267
        assertEquals(0, records.size(), "Unexpected size for " + records.toString());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   268
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   269
        Reference.reachabilityFence(app3);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   270
        Reference.reachabilityFence(system3);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   271
        System.gc();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   272
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   273
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   274
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   275
    @SuppressWarnings("deprecated")
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   276
    static void setPlatformLevel(PlatformLogger logger, PlatformLogger.Level level) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   277
        logger.setLevel(level);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   278
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   279
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   280
    public static void testSetPlatformLevel(String name, String step) {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   281
        System.out.println("\n*** Testing PlatformLogger.setLevel " + name + step);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   282
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   283
        System.out.println("\n[Case #5] Creating app logger: " + name + step);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   284
        // this should return named logger in the global context
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   285
        Logger foo = Logger.getLogger(name + step);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   286
        foo.setLevel(Level.FINE);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   287
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   288
        System.out.println("    Creating platform logger: " + name + step);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   289
        PlatformLogger foo1 = PlatformLogger.getLogger(name + step);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   290
        System.out.println("    Configuring platform logger...");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   291
        setPlatformLevel(foo1, PlatformLogger.Level.INFO);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   292
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   293
        System.out.println("    Checking levels...");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   294
        assertEquals(foo.getName(), foo1.getName(), "Bad logger names");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   295
         // both logger share the same config
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   296
        assertEquals(foo.getLevel(), Level.INFO, "Bad level for user logger");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   297
        assertEquals(foo1.level(), PlatformLogger.Level.INFO,
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   298
                "Bad level for platform logger");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   299
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   300
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   301
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   302
    static void updateConfiguration(Properties props) throws IOException {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   303
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   304
        props.store(baos, "");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   305
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   306
        LogManager.getLogManager().updateConfiguration(bais, (k) -> (o,n) -> n != null ? n : o);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   307
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   308
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   309
    static void readConfiguration(Properties props) throws IOException {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   310
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   311
        props.store(baos, "");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   312
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   313
        LogManager.getLogManager().readConfiguration(bais);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   314
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   315
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   316
    // Tests that though two loggers exist, only one handler is created for the
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   317
    // pair when reading configuration.
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   318
    //
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   319
    public static void testUpdateConfiguration(String name, String step) throws IOException {
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   320
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   321
        System.out.println("\n*** Testing LogManager.updateConfiguration " + name + step);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   322
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   323
        final String name1a = "system.logger.one.a." + name + step;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   324
        final String name1b = "system.logger.one.b." + name + step;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   325
        final String msg1a = "logger name: " + name1a;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   326
        final String msg1b = "logger name: " + name1b;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   327
        List<LogRecord> records;
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   328
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   329
        TestHandler1.COUNT.set(0);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   330
        TestHandler2.COUNT.set(0);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   331
        Properties props = new Properties();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   332
        props.setProperty(name1a+".handlers", TestHandler1.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   333
        updateConfiguration(props);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   334
        assertEquals(0, TestHandler1.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   335
                + TestHandler1.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   336
        assertEquals(0, TestHandler2.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   337
                + TestHandler2.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   338
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   339
        System.out.println("\n[Case #4] Creating app logger: " + name1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   340
        Logger app1a = Logger.getLogger(name1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   341
        System.out.println("    Configuring app logger...");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   342
        TestHandler test1 = new TestHandler();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   343
        app1a.setLevel(Level.ALL);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   344
        app1a.setUseParentHandlers(false);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   345
        app1a.addHandler(test1);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   346
        assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   347
                + TestHandler1.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   348
        assertEquals(0, TestHandler2.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   349
                + TestHandler2.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   350
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   351
        System.out.println("    Creating system logger: " + name1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   352
        Logger system1a = createSystemLogger(name1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   353
        assertEquals(Level.ALL, system1a.getLevel(), "Bad level for system logger " + name1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   354
        System.out.println("    Logging through system logger: " + name1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   355
        system1a.finest(msg1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   356
        records = test1.drain();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   357
        assertEquals(1, records.size(), "Unexpected size for " + records.toString());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   358
        assertEquals(msg1a, records.get(0).getMessage(), "Unexpected message: ");
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   359
        records = test1.drain();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   360
        assertEquals(0, records.size(), "Unexpected size for " + records.toString());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   361
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   362
        assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   363
                + TestHandler1.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   364
        assertEquals(0, TestHandler2.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   365
                + TestHandler2.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   366
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   367
        props.setProperty(name1a+".handlers", TestHandler2.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   368
        updateConfiguration(props);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   369
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   370
        assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   371
                + TestHandler1.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   372
        assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   373
                + TestHandler2.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   374
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   375
        updateConfiguration(props);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   376
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   377
        assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   378
                + TestHandler1.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   379
        assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   380
                + TestHandler2.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   381
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   382
        readConfiguration(props);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   383
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   384
        assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   385
                + TestHandler1.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   386
        // readConfiguration reset handlers but does not recreate them
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   387
        assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   388
                + TestHandler2.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   389
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   390
        updateConfiguration(props);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   391
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   392
        assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   393
                + TestHandler1.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   394
        assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   395
                + TestHandler2.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   396
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   397
        LogManager.getLogManager().reset();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   398
        updateConfiguration(props);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   399
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   400
        assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   401
                + TestHandler1.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   402
        assertEquals(2, TestHandler2.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   403
                + TestHandler2.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   404
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   405
        props.setProperty(name1a+".handlers",
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   406
                TestHandler2.class.getName() + "," + TestHandler1.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   407
        updateConfiguration(props);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   408
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   409
        assertEquals(2, TestHandler1.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   410
                + TestHandler1.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   411
        assertEquals(3, TestHandler2.COUNT.get(), "Bad instance count for "
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   412
                + TestHandler2.class.getName());
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   413
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   414
        Reference.reachabilityFence(app1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   415
        Reference.reachabilityFence(system1a);
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   416
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   417
        LogManager.getLogManager().readConfiguration();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   418
        System.gc();
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   419
    }
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   420
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   421
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   422
812020bcb9f1 8159245: Loggers created by system classes are not initialized correctly when configured programmatically from application code.
dfuchs
parents:
diff changeset
   423
}