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

DocumentationExampleTest: tests for date and number formats not working on installations with a non-English default locale. #626

Open
api-from-the-ion opened this issue Oct 31, 2023 · 1 comment
Labels
bug Something isn't working right

Comments

@api-from-the-ion
Copy link

Describe the bug
The two tests mentioned before are not working on the JRE with a non-English default locale. Cause: because in the given number format in the first test, only the pattern is set, but no locale is given, the default locale is used (see the standard description for annotation). In the case of the non-English default locale, the result JSON string could be different from the constant used in the test. Therefore, this test fails.

In the second test, there is no number formatting used because the standard doesn't give us the possibility to do so with the builder's configuration, not with annotation. There is still a question, why is it so in the standard? But aside from this, this test also only works on the installations with English as the default locale. This time, one uses the class without formatting to serialize and with formatting to deserialize. This also fails with non-English locales.

So there are two possibilities for the first test: either set both the pattern and locale in the annotations. Or respect the current default locale in the expected JSON string.

For the second test, there is only one solution: one should use the same class for serialization and deserialization. It is also a scenario that would work in the productive system: it would be hard to serialize and deserialize with such differently configured classes.

To Reproduce
Run the tests mentioned before.

Expected behavior
Tests not to fail.

System information:

  • OS: Linux
  • Java Version: 17.0.9
  • Yasson Version: 3.0.3

Additional context
I'll create a PR with the second solution.

@api-from-the-ion api-from-the-ion added the bug Something isn't working right label Oct 31, 2023
api-from-the-ion added a commit to api-from-the-ion/yasson that referenced this issue Oct 31, 2023
…locale

Signed-off-by: Anton Pinsky <anton.pinsky@ionos.com>
@api-from-the-ion
Copy link
Author

The PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working right
Projects
None yet
Development

No branches or pull requests

1 participant