test/java/util/logging/LoggingMXBeanTest2.java

Print this page
rev 6099 : 8003380: Compiler warnings in logging test code
Summary: Use generics, suppress warnings where appropriate, remove unused imports, etc.
Reviewed-by: lancea, chegar

*** 35,45 **** import java.util.List; import java.util.ListIterator; public class LoggingMXBeanTest2 { - static LoggingMXBean mbean = LogManager.getLoggingMXBean(); static String LOGGER_NAME_1 = "com.sun.management.Logger"; static String LOGGER_NAME_2 = "com.sun.management.Logger.Logger2"; static String UNKNOWN_LOGGER_NAME = "com.sun.management.Unknown"; static Logger logger1; --- 35,44 ----
*** 55,72 **** /* * Check for the existence of our new Loggers */ System.out.println("Test Logger Name retrieval (getLoggerNames)"); boolean log1 = false, log2 = false; ! List loggers = mbean.getLoggerNames(); if (loggers == null || loggers.size() < 2) { throw new RuntimeException( "Could not Detect the presense of the new Loggers"); } ! for (ListIterator iter = loggers.listIterator(); iter.hasNext(); ) { ! String logger = (String) iter.next(); if (logger.equals(LOGGER_NAME_1)) { log1 = true; System.out.println(" : Found new Logger : " + logger); } if (logger.equals(LOGGER_NAME_2)) { --- 54,71 ---- /* * Check for the existence of our new Loggers */ System.out.println("Test Logger Name retrieval (getLoggerNames)"); boolean log1 = false, log2 = false; ! List<String> loggers = mbean.getLoggerNames(); if (loggers == null || loggers.size() < 2) { throw new RuntimeException( "Could not Detect the presense of the new Loggers"); } ! for (ListIterator<String> iter = loggers.listIterator(); iter.hasNext(); ) { ! String logger = iter.next(); if (logger.equals(LOGGER_NAME_1)) { log1 = true; System.out.println(" : Found new Logger : " + logger); } if (logger.equals(LOGGER_NAME_2)) {
*** 185,192 **** " but got " + p3); } } public static void main(String[] argv) throws Exception { ! LoggingMXBeanTest2 p = new LoggingMXBeanTest2(); } } --- 184,191 ---- " but got " + p3); } } public static void main(String[] argv) throws Exception { ! new LoggingMXBeanTest2(); } }