Updating Map tests.
This commit is contained in:
parent
bf4ab04413
commit
5af0b16641
@ -157,12 +157,7 @@ public class MapTest extends TestCase {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void testParameterizedMapSubclassDeserialization() {
|
public void testParameterizedMapSubclassDeserialization() {
|
||||||
Type type = new TypeToken<MyParameterizedMap<String, Integer>>() {}.getType();
|
Type type = new TypeToken<MyParameterizedMap<String, Integer>>() {}.getType();
|
||||||
Gson gson = new GsonBuilder().registerTypeAdapter(type,
|
Gson gson = new Gson();
|
||||||
new InstanceCreator<MyParameterizedMap>() {
|
|
||||||
public MyParameterizedMap createInstance(Type type) {
|
|
||||||
return new MyParameterizedMap();
|
|
||||||
}
|
|
||||||
}).create();
|
|
||||||
String json = "{\"a\":1,\"b\":2}";
|
String json = "{\"a\":1,\"b\":2}";
|
||||||
MyParameterizedMap<String, Integer> map = gson.fromJson(json, type);
|
MyParameterizedMap<String, Integer> map = gson.fromJson(json, type);
|
||||||
assertEquals(1, map.get("a").intValue());
|
assertEquals(1, map.get("a").intValue());
|
||||||
@ -191,7 +186,7 @@ public class MapTest extends TestCase {
|
|||||||
assertEquals("2", map.get("b"));
|
assertEquals("2", map.get("b"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable_testMapSubclassDeserialization() {
|
public void testMapSubclassDeserialization() {
|
||||||
Gson gson = new GsonBuilder().registerTypeAdapter(MyMap.class, new InstanceCreator<MyMap>() {
|
Gson gson = new GsonBuilder().registerTypeAdapter(MyMap.class, new InstanceCreator<MyMap>() {
|
||||||
public MyMap createInstance(Type type) {
|
public MyMap createInstance(Type type) {
|
||||||
return new MyMap();
|
return new MyMap();
|
||||||
|
Loading…
Reference in New Issue
Block a user