Created
November 11, 2013 14:01
-
-
Save asafjaffi/7413605 to your computer and use it in GitHub Desktop.
Testing to see when the Locale deserializer works
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.util.HashMap; | |
import java.util.Locale; | |
import java.util.Map; | |
import org.codehaus.jackson.JsonGenerationException; | |
import org.codehaus.jackson.map.JsonMappingException; | |
import org.codehaus.jackson.map.ObjectMapper; | |
import org.codehaus.jackson.type.TypeReference; | |
import org.junit.Test; | |
public class LocaleMappingWithJacksonTest { | |
@Test | |
public void testLocaleMapping() throws JsonGenerationException, JsonMappingException, IOException { | |
ObjectMapper mapper = new ObjectMapper(); | |
Map<String, Locale> writeMap = new HashMap<String, Locale>(); | |
writeMap.put("key", Locale.ENGLISH); | |
String json = mapper.writeValueAsString(writeMap); | |
HashMap<String, Locale> readMap = mapper.readValue(json, | |
new TypeReference<HashMap<String, Locale>>() { | |
}); | |
assertEquals(Locale.ENGLISH, readMap.get("key")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment