Skip to content

test: pin the default locale in SpringDocApp238Test - #3380

Open
sharanggupta wants to merge 1 commit into
springdoc:mainfrom
sharanggupta:fix-locale-dependent-app238-test
Open

sharanggupta wants to merge 1 commit into
springdoc:mainfrom
sharanggupta:fix-locale-dependent-app238-test

Conversation

@sharanggupta

Copy link
Copy Markdown

Fixes #3379

SpringDocApp238Test (v30 and v31) fails on hosts whose default locale is en_GB: ResourceBundleMessageSource falls back to the JVM default locale before the base bundle, so the en-US and zh-CN (mapped to en-US) lookups pick up messages_en_GB.properties and the fixtures no longer match.

This change pins the default locale to en-US for the duration of the test class and restores the previous value afterwards, mirroring SpringDocApp14Test. No production code or fixtures change.

Verified:

  • mvn -pl springdoc-openapi-starter-webmvc-api test -Dtest=SpringDocApp238Test -DargLine="-Duser.language=en -Duser.country=GB" fails before, passes after
  • the same with -Duser.country=US passes
  • mvn -pl springdoc-openapi-starter-webmvc-api test -DargLine="-Duser.language=en -Duser.country=GB": 653 tests, 0 failures

SpringDocApp238Test resolves the @Info title and the tag names through a
ResourceBundleMessageSource for en-US, fr-CA and zh-CN and compares the
output with fixtures written for the base messages.properties bundle.
ResourceBundleMessageSource falls back to the JVM default locale before
the base bundle, so on a machine whose default locale is en_GB the en-US
request (and the zh-CN one, which the allowed-locales setting maps to
en-US) picks up messages_en_GB.properties and the test fails with
"This is a test message[EN_GB]".

Pin the default locale to en-US for the duration of the class and
restore it afterwards, as SpringDocApp14Test already does, so the
fixtures are deterministic regardless of the host locale.

Fixes springdoc#3379

This branch has not been deployed

No deployments
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.

SpringDocApp238Test fails when the JVM default locale is en_GB

1 participant