Permalink
Browse files

Restore initial locale at the end of a JUnit test case which modify it.

  • Loading branch information...
luccioman committed Nov 20, 2017
1 parent 7206f1e commit d41ad7af6f8ee9d4edde8dfc00bf28a6bc8b7ce4
Showing with 13 additions and 4 deletions.
  1. +13 −4 test/java/net/yacy/document/TextParserTest.java
@@ -44,11 +44,20 @@
*/
@Test
public void testSupportsMimeLocaleConsistency() {
for (Locale locale : Locale.getAvailableLocales()) {
Locale.setDefault(locale);
for (String mimeType : TextParser.supportedMimeTypes()) {
assertNull(locale + " " + mimeType, TextParser.supportsMime(mimeType.toUpperCase(Locale.ROOT)));
Locale initialDefaultLocale = Locale.getDefault();
try {
for (Locale locale : Locale.getAvailableLocales()) {
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);
}
}

0 comments on commit d41ad7a

Please sign in to comment.