diff options
author | Almaz Mingaleev <mingaleev@google.com> | 2022-08-26 14:30:46 +0100 |
---|---|---|
committer | Almaz Mingaleev <mingaleev@google.com> | 2022-08-26 15:31:20 +0100 |
commit | b4a48320059e3469c14dabb57a6f32c45e041a76 (patch) | |
tree | 7ec13b5388790e60a5c4c16f0b51ab4a5ee04db0 | |
parent | 342b84cc53b4fc9ded8eb4498cfed39a01f7bbe2 (diff) | |
download | apache-harmony-b4a48320059e3469c14dabb57a6f32c45e041a76.tar.gz |
Deflake SimpleFormatterTest.
This test was passing on UTC, Europe/London and
America/Los_Angeles, but failing on Nuuk or America/Santiago.
Bug was in current year calculation: LogRecord's time is set to 0,
but Calendar was set to 12321312 millis, which about 3.5 hours. So,
if time zone's offset is negative and small enough 0 and 12321312
epoch millis will be in different years - in 1969 and 1970
correspondingly.
Bug: 155075213
Fix: 155075213
Test: atest CtsLibcoreTestCases:org.apache.harmony.logging.tests.java.util.logging.SimpleFormatterTest
Test: passes will all the time zones mentioned above
Change-Id: I19b214c5a809d084e5ed1b67aca96f9c44b2519b
-rw-r--r-- | logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SimpleFormatterTest.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SimpleFormatterTest.java b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SimpleFormatterTest.java index ee35d2d..02421a8 100644 --- a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SimpleFormatterTest.java +++ b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/SimpleFormatterTest.java @@ -74,6 +74,7 @@ public class SimpleFormatterTest extends TestCase { } public void testFormat() { + long logEventTimeMillis = 0; String str = sf.format(lr); Throwable t; @@ -92,10 +93,10 @@ public class SimpleFormatterTest extends TestCase { } }); lr.setSequenceNumber(12321312); - lr.setMillis(0); + lr.setMillis(logEventTimeMillis); str = sf.format(lr); Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(12321312); + cal.setTimeInMillis(logEventTimeMillis); assertTrue(str.indexOf(String.valueOf(cal.get(Calendar.YEAR))) >= 0); assertTrue(str.indexOf("class") > 0); assertTrue(str.indexOf("method") > 0); |