eclipse-ee4j / eclipse-ee4j/yasson
DocumentationExampleTest: tests for date and number formats not working on installations with a non-English default locale.
- Dominant language
- Java
- Stars
- 218
- Forks
- 109
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 9
Description
**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.
Contributor guide
Research direction
Start with DocumentationExampleTest and run the date- and number-format tests under a non-English default locale. Update the first test's locale handling and make the second use the same configured class for serialization and deserialization; done means both tests pass without depending on an English default locale.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100