From d678e2c0dc877d512e352a99f493605432046005 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Fri, 10 Oct 2014 12:05:32 +0200 Subject: [PATCH] 8042147: test sun/util/logging/SourceClassName.java failed: Unexpected source: java.util.Currency info The test should allow for the possibility that something else than the test code itself might log during the test. Reviewed-by: lancea --- .../sun/util/logging/SourceClassName.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/jdk/test/sun/util/logging/SourceClassName.java b/jdk/test/sun/util/logging/SourceClassName.java index e662166ab46..886460b7dad 100644 --- a/jdk/test/sun/util/logging/SourceClassName.java +++ b/jdk/test/sun/util/logging/SourceClassName.java @@ -54,7 +54,8 @@ public class SourceClassName { 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 @@ public class SourceClassName { 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 @@ public class SourceClassName { 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) {