Skip to content

fix: resolve brittle timezone test in TestPureDate#4533

Open
kapilhadoltikar wants to merge 1 commit intofinos:masterfrom
kapilhadoltikar:fix/issue_#4531_timezone_test
Open

fix: resolve brittle timezone test in TestPureDate#4533
kapilhadoltikar wants to merge 1 commit intofinos:masterfrom
kapilhadoltikar:fix/issue_#4531_timezone_test

Conversation

@kapilhadoltikar
Copy link

Description

This PR addresses the brittle assertion failures in TestPureDate.testFormatWithTimeZoneShift reported in #4531.

The root cause was a dependency on the JDK's default Locale Provider. In modern environments (JDK 9+ using CLDR), the z format specifier often resolves to a localized GMT offset (e.g., GMT-06:00) instead of the alphanumeric abbreviation (e.g., CST). This caused strict string equality tests to fail despite the date-time logic being correct.

Changes

  • Refactored Test Logic: Replaced hardcoded string assertions with a private helper method assertDateWithZone.
  • Regex Validation: The helper method uses Regex to allow for both shorthand zone IDs and GMT offsets, making the test suite environment-agnostic.
  • Improved Error Reporting: Added descriptive assertion messages to simplify debugging for future environmental mismatches.

Verification Results

  • Environment: Windows 11, OpenJDK Temurin 11.0.30, Maven 3.9.11
  • Test Result: TestPureDate now passes successfully (15/15 tests).

Related Issues

Checklist

  • Commits are signed-off (-s)
  • Verified locally with mvn clean test -Dtest=TestPureDate
  • No breaking changes to the PureDate domain logic

Test Fail

Failure

Test Success

Success

Updated testFormatWithTimeZoneShift to accept both shorthand abbreviations (CST) and GMT offsets (GMT-06:00).
Refactored repeated logic into a regex-based helper method for better maintainability.

Closes Issue finos#4531

Signed-off-by: kapilh <146179927+kapilhadoltikar@users.noreply.github.com>
@kapilhadoltikar kapilhadoltikar requested a review from a team as a code owner March 10, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Environment-agnostic TimeZone formatting in TestPureDate

1 participant