Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BindAdviceTraitTest's test failure. message is not following locale(English) setting. #905

Open
arthur-yoon opened this issue Apr 14, 2023 · 5 comments
Labels

Comments

@arthur-yoon
Copy link

Description

In the BindAdviceTraitTest class, when the locale is set to English by LocaleContextHolder.setLocale(Locale.ENGLISH) in the setUp method with BeforeEach, problem.getViolations().get(*).getMessage() is output in Korean according to my locale instead of English.

Expected Behavior

problem.getViolations().get().getMessage() is "size must be between 3 and 10".
problem.getViolations().get(
).getMessage() is "must be greater than or equal to 0".

Actual Behavior

problem.getViolations().get().getMessage() is "크기가 3에서 10 사이여야 합니다"
problem.getViolations().get(
).getMessage() is "0 이상이어야 합니다"
image

Possible Fix

Steps to Reproduce

Context

Your Environment

  • Version used: 0.29.0-SNAPSHOT
  • Link to your project: nothing changed yet. just test case failures
@whiskeysierra
Copy link
Collaborator

whiskeysierra commented Apr 14, 2023 via email

@cberg-zalando
Copy link
Member

I at least experience the same with my laptop being set to German, so I also get issues with the test execution.

@arthur-yoon
Copy link
Author

LocaleContextHolder.setLocale(Locale.ENGLISH

it's not enough to call LocaleContextHolder.setLocale(Locale.ENGLISH), which sets the Locale information used by Spring.
LocaleContextHolder.setLocale(Locale.ENGLISH) sets the locale to English for the just current thread. However, the error messages used by Bean Validation are obtained from Spring's MessageSource, which by default uses the operating system's default locale.

@arthur-yoon
Copy link
Author

I at least experience the same with my laptop being set to German, so I also get issues with the test execution.

It's correct to use English as the message source instead of changing the locale setting, but I don't think this is a good idea, because if the message.properties are changed, the test case will eventually break. Shouldn't we modify it to something other than testing if the sentences match?

@arthur-yoon
Copy link
Author

is this issue handled?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants