From 8c942d2a67bb646af5469fd31d3110e95405b2d5 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 10 Aug 2023 15:21:49 -0400 Subject: [PATCH] Better test failure message --- .../time/FastDateParser_TimeZoneStrategyTest.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java index 46fbdd92b..a6d718bcc 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java @@ -21,12 +21,16 @@ import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assumptions.assumeFalse; import static org.junit.jupiter.api.Assumptions.assumeTrue; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; import java.text.DateFormatSymbols; import java.text.ParseException; +import java.util.Arrays; import java.util.Date; import java.util.Locale; import java.util.Objects; import java.util.TimeZone; +import java.util.stream.Stream; import org.apache.commons.lang3.AbstractLangTest; import org.apache.commons.lang3.LocaleUtils; @@ -71,9 +75,13 @@ public class FastDateParser_TimeZoneStrategyTest extends AbstractLangTest { try { parser.parse(tzDisplay); } catch (final ParseException e) { + // Missing "Zulu" or something else in broken GH builds? + final ByteArrayOutputStream zonesOut = new ByteArrayOutputStream(); + final PrintStream zonesPs = new PrintStream(zonesOut); + Stream.of(zones).forEach(z -> zonesPs.println(Arrays.toString(z))); fail(String.format( - "%s: with tzDefault = %s, locale = %s, zones[][] size = '%s', zone[] size = '%s', zIndex = %,d, tzDisplay = '%s', parser = '%s'", e, - tzDefault, locale, zones.length, zone.length, zIndex, tzDisplay, parser.toStringAll()), e); + "%s: with tzDefault = %s, locale = %s, zones[][] size = '%s', zIndex = %,d, tzDisplay = '%s', parser = '%s', zones = %s", e, + tzDefault, locale, zone.length, zIndex, tzDisplay, parser.toStringAll(), zones.length, zonesOut), e); } } }