Fix ObjectTest not restoring default Locale (#2050)

This commit is contained in:
Marcono1234 2022-01-10 16:18:42 +01:00 committed by GitHub
parent 4ec67c00a0
commit d38e397421
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,22 +55,27 @@ import junit.framework.TestCase;
*/
public class ObjectTest extends TestCase {
private Gson gson;
private TimeZone oldTimeZone = TimeZone.getDefault();
private TimeZone oldTimeZone;
private Locale oldLocale;
@Override
protected void setUp() throws Exception {
super.setUp();
gson = new Gson();
oldTimeZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
oldLocale = Locale.getDefault();
Locale.setDefault(Locale.US);
}
@Override
protected void tearDown() throws Exception {
TimeZone.setDefault(oldTimeZone);
Locale.setDefault(oldLocale);
super.tearDown();
}
public void testJsonInSingleQuotesDeserialization() {
String json = "{'stringValue':'no message','intValue':10,'longValue':20}";
BagOfPrimitives target = gson.fromJson(json, BagOfPrimitives.class);