-
-
Notifications
You must be signed in to change notification settings - Fork 426
Maven test - Fix locale issue #55
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
Conversation
Test "testGetMediaInformation()" fails in environment where default locale has a comma as decimal mark: German, French...
FFmpegFormat format = probeResult.getFormat(); | ||
String line1 = | ||
String.format("File: '%s' ; Format: '%s' ; Duration: %.3fs", format.filename, | ||
String.format(Locale.US, "File: '%s' ; Format: '%s' ; Duration: %.3fs", format.filename, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just call Locale.setDefault before the test, to avoid cluttering up the example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method Locale#setDefault(Locale)
changes locale for the instance of the JVM. I would rather use a specific locale only for this test ; maybe via a local field ?
We should also ensure tests are OK whatever the OS language or file encoding. I have not found the way to configure these in Travis-CI. |
I agree tests should work regardless of the Locale. However, in this case we are depending on the specific formatting, and I want to keep the documentation simple. I would only want Locale.setDefault for this one test. Can we now Locale.setDefault in a setup, and undo it in a teardown method? |
Use method Locale#setDefault(Locale) to force default local temporarily.
I have added some cumbersome code to use However, this code is not thread-safe and can have side-effects with Parallel Test Execution. |
You make a good case that this code is no longer thread-safe. So perhaps we annotate with @NotThreadSafe, or perhaps we just change the test to use format(locale,...), and keep the README the simple. |
Ensure Maven tests are OK for any language/file encoding.