Fix ObjectTest not restoring default Locale (#2050)
This commit is contained in:
parent
4ec67c00a0
commit
d38e397421
@ -55,22 +55,27 @@ import junit.framework.TestCase;
|
|||||||
*/
|
*/
|
||||||
public class ObjectTest extends TestCase {
|
public class ObjectTest extends TestCase {
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
private TimeZone oldTimeZone = TimeZone.getDefault();
|
private TimeZone oldTimeZone;
|
||||||
|
private Locale oldLocale;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
gson = new Gson();
|
gson = new Gson();
|
||||||
|
|
||||||
|
oldTimeZone = TimeZone.getDefault();
|
||||||
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
|
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
|
||||||
|
oldLocale = Locale.getDefault();
|
||||||
Locale.setDefault(Locale.US);
|
Locale.setDefault(Locale.US);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
TimeZone.setDefault(oldTimeZone);
|
TimeZone.setDefault(oldTimeZone);
|
||||||
|
Locale.setDefault(oldLocale);
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testJsonInSingleQuotesDeserialization() {
|
public void testJsonInSingleQuotesDeserialization() {
|
||||||
String json = "{'stringValue':'no message','intValue':10,'longValue':20}";
|
String json = "{'stringValue':'no message','intValue':10,'longValue':20}";
|
||||||
BagOfPrimitives target = gson.fromJson(json, BagOfPrimitives.class);
|
BagOfPrimitives target = gson.fromJson(json, BagOfPrimitives.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user