package net.sf.jabref.logic.l10n;

import org.junit.Test;

import java.util.Locale;

import static org.junit.Assert.assertEquals;

public class LocalizationTest {

    @Test
    public void testSetKnownLanguage() {
        Locale.setDefault(Locale.CHINA);
        Localization.setLanguage("en");
        assertEquals("en", Locale.getDefault().toString());
    }

    @Test
    public void testSetUnknownLanguage() {
        Locale.setDefault(Locale.CHINA);
        Localization.setLanguage("WHATEVER");
        assertEquals(Locale.CHINA.toString(), Locale.getDefault().toString());
    }

    @Test
    public void testKnownTranslation() {
        Localization.setLanguage("en");
        String knownKey = "Groups";
        assertEquals(knownKey, Localization.lang(knownKey));
        assertEquals(knownKey, Localization.menuTitle(knownKey));
    }

    @Test
    public void testUnknownTranslation() {
        Localization.setLanguage("en");
        String knownKey = "WHATEVER";
        assertEquals(knownKey, Localization.lang(knownKey));
        assertEquals(knownKey, Localization.menuTitle(knownKey));
    }

}
@@ -200,32 +200,96 @@
 ownLanguage() %7B%0A
+        Locale before = Locale.getDefault();%0A%0A        try %7B%0A    
         Locale.s
@@ -305,32 +305,36 @@
 (Locale.CHINA);%0A
+    
         Localiza
@@ -349,32 +349,36 @@
 Language(%22en%22);%0A
+    
         assertEq
@@ -413,32 +413,101 @@
 ().toString());%0A
+        %7D finally %7B%0A            Locale.setDefault(before);%0A        %7D%0A
     %7D%0A%0A    @Test
@@ -542,32 +542,96 @@
 ownLanguage() %7B%0A
+        Locale before = Locale.getDefault();%0A%0A        try %7B%0A    
         Locale.s
@@ -655,32 +655,36 @@
 CHINA);%0A        
+ 
+   
 Localization.set
@@ -701,24 +701,28 @@
 WHATEVER%22);%0A
+    
         asse
@@ -784,24 +784,93 @@
 oString());%0A
+        %7D finally %7B%0A            Locale.setDefault(before);%0A        %7D%0A
     %7D%0A%0A    @
@@ -907,32 +907,96 @@
 Translation() %7B%0A
+        Locale before = Locale.getDefault();%0A%0A        try %7B%0A    
         Localiza
@@ -1019,32 +1019,36 @@
 (%22en%22);%0A        
+   
+ 
 String knownKey 
@@ -1059,16 +1059,20 @@
 roups%22;%0A
+    
         
@@ -1116,32 +1116,36 @@
 ang(knownKey));%0A
+    
         assertEq
@@ -1190,24 +1190,93 @@
 knownKey));%0A
+        %7D finally %7B%0A            Locale.setDefault(before);%0A        %7D%0A
     %7D%0A%0A    @
@@ -1315,32 +1315,96 @@
 Translation() %7B%0A
+        Locale before = Locale.getDefault();%0A%0A        try %7B%0A    
         Localiza
@@ -1427,32 +1427,36 @@
 (%22en%22);%0A        
+ 
+   
 String knownKey 
@@ -1469,16 +1469,20 @@
 TEVER%22;%0A
+    
         
@@ -1534,32 +1534,36 @@
 nKey));%0A        
+  
+  
 assertEquals(kno
@@ -1600,20 +1600,89 @@
 knownKey));%0A
+        %7D finally %7B%0A            Locale.setDefault(before);%0A        %7D%0A
     %7D%0A%0A%7D

Fix tests.