Skip to content

Commit

Permalink
Restore initial locale at the end of a JUnit test case which modify it.
Browse files Browse the repository at this point in the history
  • Loading branch information
luccioman committed Nov 20, 2017
1 parent 7206f1e commit d41ad7a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions test/java/net/yacy/document/TextParserTest.java
Expand Up @@ -44,11 +44,20 @@ public class TextParserTest {
*/ */
@Test @Test
public void testSupportsMimeLocaleConsistency() { public void testSupportsMimeLocaleConsistency() {
for (Locale locale : Locale.getAvailableLocales()) { Locale initialDefaultLocale = Locale.getDefault();
Locale.setDefault(locale); try {
for (String mimeType : TextParser.supportedMimeTypes()) { for (Locale locale : Locale.getAvailableLocales()) {
assertNull(locale + " " + mimeType, TextParser.supportsMime(mimeType.toUpperCase(Locale.ROOT))); Locale.setDefault(locale);
for (String mimeType : TextParser.supportedMimeTypes()) {
assertNull(locale + " " + mimeType, TextParser.supportsMime(mimeType.toUpperCase(Locale.ROOT)));
}
} }
} finally {
/*
* Restore the initial default locale to prevent side-effects on other JUnit
* tests run in the same session
*/
Locale.setDefault(initialDefaultLocale);
} }
} }


Expand Down

0 comments on commit d41ad7a

Please sign in to comment.