# HG changeset patch # User dfuchs # Date 1412935532 -7200 # Node ID 6157b22bd081d3c52b012d76a1300f4b5ab7fa10 # Parent a137992d750c72f6f944f341aa19b0d0d96afe0c 8042147: test sun/util/logging/SourceClassName.java failed: Unexpected source: java.util.Currency info Summary: the test should allow for the possibility that something else than the test code itself might log during the test. Reviewed-by: lancea diff -r a137992d750c -r 6157b22bd081 jdk/test/sun/util/logging/SourceClassName.java --- a/jdk/test/sun/util/logging/SourceClassName.java Wed Jul 05 20:04:04 2017 +0200 +++ b/jdk/test/sun/util/logging/SourceClassName.java Fri Oct 10 12:05:32 2014 +0200 @@ -54,7 +54,8 @@ plog.severe("Log message {0} {1}", (Object[]) params); // create a java.util.logging.Logger - // now java.util.logging.Logger should be created for each platform logger + // now java.util.logging.Logger should be created for each platform + // logger Logger logger = Logger.getLogger("test.log.bar"); logger.log(Level.SEVERE, "Log message {0} {1}", params); @@ -82,6 +83,19 @@ record[i++] = line; if (i == 2) { i = 0; + // check log message + if (!record[1].equals(EXPECTED_LOG)) { + // it can sometime happen that some static initializer + // in the system will log an error message - due to e.g. + // some kind of misconfiguration or system settings. + // For instance - somethink like: + // INFO: currency.properties entry for FR ignored + // because the value format is not recognized. + // instead of failing if we get such an unexpected + // message, we will simply print that out. + System.out.println("*** WARNING: Unexpected log: " + record[1]); + continue; + } count++; // check source class name and method String[] ss = record[0].split("\\s+"); @@ -92,10 +106,6 @@ ss[len-2] + " " + ss[len-1]); } - // check log message - if (!record[1].equals(EXPECTED_LOG)) { - throw new RuntimeException("Unexpected log: " + record[1]); - } } } if (count != 3) {