From 8d6933daf6cacccab1558d2564711c94aeb20a11 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sun, 21 Feb 2021 11:36:24 -0500 Subject: [PATCH] Better assertion failure messages. --- .../lang3/time/FastDateParserTest.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java index 0a1e43698..38eda0b48 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -122,20 +122,22 @@ private static Calendar initializeCalendar(final TimeZone timeZone) { static void checkParse(final Locale locale, final Calendar cal, final SimpleDateFormat simpleDateFormat, final DateParser dateParser) { final String formattedDate = simpleDateFormat.format(cal.getTime()); - checkParse(locale, simpleDateFormat, dateParser, formattedDate); - checkParse(locale, simpleDateFormat, dateParser, formattedDate.toLowerCase(locale)); - checkParse(locale, simpleDateFormat, dateParser, formattedDate.toUpperCase(locale)); + checkParse(locale, simpleDateFormat, dateParser, formattedDate, formattedDate); + checkParse(locale, simpleDateFormat, dateParser, formattedDate.toLowerCase(locale), formattedDate); + checkParse(locale, simpleDateFormat, dateParser, formattedDate.toUpperCase(locale), formattedDate); } static void checkParse(final Locale locale, final SimpleDateFormat simpleDateFormat, final DateParser dateParser, - final String formattedDate) { + final String formattedDate, final String originalFormattedDate) { try { final Date expectedTime = simpleDateFormat.parse(formattedDate); final Date actualTime = dateParser.parse(formattedDate); - assertEquals(expectedTime, actualTime, "locale : " + locale + ", formattedDate : " + formattedDate - + ", Java: " + SystemUtils.JAVA_RUNTIME_VERSION + "\n"); + assertEquals(expectedTime, actualTime, + "locale: " + locale + ", formattedDate: '" + formattedDate + "', originalFormattedDate: '" + + originalFormattedDate + ", simpleDateFormat.pattern: '" + simpleDateFormat + "', Java: " + + SystemUtils.JAVA_RUNTIME_VERSION + "\n"); } catch (final Exception e) { - fail("locale : " + locale + " formattedDate : " + formattedDate + " error : " + e + "\n", e); + fail("locale: " + locale + ", formattedDate: '" + formattedDate + "', error : " + e + "\n", e); } } @@ -691,7 +693,8 @@ private void validateSdfFormatFdpParseEquality(final String format, final Locale final String fmt = sdf.format(in); try { final Date out = fdp.parse(fmt); - assertEquals(in, out, locale.toString() + " " + in + " " + format + " " + tz.getID()); + assertEquals(in, out, + "Locale: " + locale + ", date: " + in + ", format: '" + format + "', time zone: " + tz.getID()); } catch (final ParseException pe) { if (year >= 1868 || !locale.getCountry().equals("JP")) {// LANG-978 throw pe;