summaryrefslogtreecommitdiff
path: root/test/java
diff options
context:
space:
mode:
authorluccioman <luccioman@users.noreply.github.com>2017-11-20 18:50:49 +0100
committerluccioman <luccioman@users.noreply.github.com>2017-11-20 18:50:49 +0100
commitd41ad7af6f8ee9d4edde8dfc00bf28a6bc8b7ce4 (patch)
tree98e1bb610f3a1a09b7a4b72148c59800a010e883 /test/java
parent7206f1ed711008ef529d6f103f003cccfdab99b2 (diff)
Restore initial locale at the end of a JUnit test case which modify it.
Diffstat (limited to 'test/java')
-rw-r--r--test/java/net/yacy/document/TextParserTest.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/test/java/net/yacy/document/TextParserTest.java b/test/java/net/yacy/document/TextParserTest.java
index 2d874d592..6600216f2 100644
--- a/test/java/net/yacy/document/TextParserTest.java
+++ b/test/java/net/yacy/document/TextParserTest.java
@@ -44,11 +44,20 @@ public class TextParserTest {
*/
@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);
}
}