test/jdk/java/util/logging/LoggingMXBeanTest.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:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
35768
7066da300a08 8149391: Fix module dependences in java/util tests
shurailine
parents: 14683
diff changeset
     2
 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug     5007165
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * @summary Basic Test for LoggingMXBean via MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * @author  Ron Mann
35768
7066da300a08 8149391: Fix module dependences in java/util tests
shurailine
parents: 14683
diff changeset
    30
 * @modules java.logging
7066da300a08 8149391: Fix module dependences in java/util tests
shurailine
parents: 14683
diff changeset
    31
 *          java.management
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * @build LoggingMXBeanTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * @run main LoggingMXBeanTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.management.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.logging.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public class LoggingMXBeanTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    LoggingMXBean mBean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    ObjectName objectName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    static String LOGGER_NAME_1 = "com.sun.management.Logger1";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    static String LOGGER_NAME_2 = "com.sun.management.Logger2";
14181
f723098d438c 7146552: java/util/logging/LoggingMXBeanTest.java failing intermittently
jgish
parents: 5506
diff changeset
    47
    static Logger logger1;
f723098d438c 7146552: java/util/logging/LoggingMXBeanTest.java failing intermittently
jgish
parents: 5506
diff changeset
    48
    static Logger logger2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    public LoggingMXBeanTest() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
         * Create the MBeanServeri, register the LoggingMXBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        System.out.println( "***************************************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        System.out.println( "********** LoggingMXBean Unit Test **********" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        System.out.println( "***************************************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        System.out.println( "" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        System.out.println( "*******************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        System.out.println( "*********** Phase 1 ***********" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        System.out.println( "*******************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        System.out.println( "    Creating MBeanServer " );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        System.out.print( "    Register LoggingMXBean: " );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        MBeanServer mbs = MBeanServerFactory.createMBeanServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        String[] list = new String[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            objectName = new ObjectName(LogManager.LOGGING_MXBEAN_NAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            mBean = LogManager.getLoggingMXBean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            mbs.registerMBean( mBean, objectName );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        catch ( Exception e ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            System.out.println( "FAILED" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        System.out.println( "PASSED" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        System.out.println("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
         * Access our MBean to get the current list of Loggers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        System.out.println( "*******************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        System.out.println( "*********** Phase 2 ***********" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        System.out.println( "*******************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        System.out.println( "   Test Logger Name retrieval (getLoggerNames) " );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        // check that Level object are returned properly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            list = (String[]) mbs.getAttribute( objectName,  "LoggerNames" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        catch ( Exception e ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            System.out.println("    : FAILED" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
         * Dump the list of Loggers already present, if any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        Object[] params =  new Object[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        String[] signature =  new String[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        Level l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        if ( list == null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            System.out.println("    : PASSED.  No Standard Loggers Present" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            System.out.println("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            System.out.println("    : PASSED. There are " + list.length + " Loggers Present" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            System.out.println("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            System.out.println( "*******************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            System.out.println( "*********** Phase 2B **********" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            System.out.println( "*******************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            System.out.println( " Examine Existing Loggers" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            for ( int i = 0; i < list.length; i++ ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                    params[0] = list[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                    signature[0] = "java.lang.String";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                    String levelName = (String) mbs.invoke(  objectName, "getLoggerLevel", params, signature );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                    System.out.println("    : Logger #" + i + " = " + list[i] );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                    System.out.println("    : Level = " + levelName );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                catch ( Exception e ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    System.out.println("    : FAILED" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                    throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            System.out.println("    : PASSED" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
         * Create two new loggers to the list of Loggers already present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        System.out.println("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        System.out.println( "*******************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        System.out.println( "*********** Phase 3 ***********" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        System.out.println( "*******************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        System.out.println( " Create and test new Loggers" );
14181
f723098d438c 7146552: java/util/logging/LoggingMXBeanTest.java failing intermittently
jgish
parents: 5506
diff changeset
   137
        logger1 = Logger.getLogger( LOGGER_NAME_1 );
f723098d438c 7146552: java/util/logging/LoggingMXBeanTest.java failing intermittently
jgish
parents: 5506
diff changeset
   138
        logger2 = Logger.getLogger( LOGGER_NAME_2 );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        // check that Level object are returned properly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            list = (String[]) mbs.getAttribute( objectName,  "LoggerNames" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        catch ( Exception e ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            System.out.println("    : FAILED" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
         *  Check for the existence of our new Loggers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        boolean log1 = false, log2 = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        if ( list == null || list.length < 2 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            System.out.println("    : FAILED.  Could not Detect the presense of the new Loggers" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            throw new RuntimeException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                "Could not Detect the presense of the new Loggers");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            for ( int i = 0; i < list.length; i++ ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                if ( list[i].equals( LOGGER_NAME_1 ) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                    log1 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                    System.out.println( "    : Found new Logger : " + list[i] );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                if ( list[i].equals( LOGGER_NAME_2 ) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                    log2 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    System.out.println( "    : Found new Logger : " + list[i] );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            if ( log1 && log2 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                System.out.println( "    : PASSED." );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                System.out.println( "    : FAILED.  Could not Detect the new Loggers." );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                throw new RuntimeException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    "Could not Detect the presense of the new Loggers");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
         *  Set a new Logging levels and check that it succeeded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        System.out.println("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        System.out.println( "*******************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        System.out.println( "*********** Phase 4 ***********" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        System.out.println( "*******************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        System.out.println( " Set and Check the Logger Level" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        log1 = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        log2 = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            // Set the level of logger1 to ALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            params = new Object[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            signature =  new String[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            params[0] = LOGGER_NAME_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            params[1] = Level.ALL.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            signature[0] = "java.lang.String";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            signature[1] = "java.lang.String";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            mbs.invoke(  objectName, "setLoggerLevel", params, signature );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            // Set the level of logger2 to FINER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            params[0] = LOGGER_NAME_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            params[1] = Level.FINER.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            mbs.invoke(  objectName, "setLoggerLevel", params, signature );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            // Okay read back the Level from Logger1. Should be ALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            params =  new Object[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            signature =  new String[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            params[0] = LOGGER_NAME_1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            signature[0] = "java.lang.String";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            String levelName = (String) mbs.invoke(  objectName, "getLoggerLevel", params, signature );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            l = Level.parse(levelName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            System.out.print("    Logger1: " );
14683
38921a46c62d 8003380: Compiler warnings in logging test code
jgish
parents: 14181
diff changeset
   212
            if ( l.equals( Level.ALL ) ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                System.out.println("Level Set to ALL: PASSED" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                log1 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                System.out.println("Level Set to ALL: FAILED" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                throw new RuntimeException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                    "Level Set to ALL but returned " + l.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            // Okay read back the Level from Logger2. Should be FINER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            params =  new Object[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            signature =  new String[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            params[0] = LOGGER_NAME_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            signature[0] = "java.lang.String";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            levelName = (String) mbs.invoke(  objectName, "getLoggerLevel", params, signature );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            l = Level.parse(levelName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            System.out.print("    Logger2: " );
14683
38921a46c62d 8003380: Compiler warnings in logging test code
jgish
parents: 14181
diff changeset
   230
            if ( l.equals( Level.FINER ) ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                System.out.println("Level Set to FINER: PASSED" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                log2 = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                System.out.println("Level Set to FINER: FAILED" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                throw new RuntimeException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                    "Level Set to FINER but returned " + l.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        catch ( Exception e ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        System.out.println( "" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        System.out.println( "***************************************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        System.out.println( "***************** All Tests Passed ****************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        System.out.println( "***************************************************" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    public static void main(String[] argv) throws Exception {
14683
38921a46c62d 8003380: Compiler warnings in logging test code
jgish
parents: 14181
diff changeset
   251
        new LoggingMXBeanTest();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
}