aboutsummaryrefslogtreecommitdiff
path: root/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java')
-rw-r--r--gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java b/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java
index 534c398d..1cff909e 100644
--- a/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java
+++ b/gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java
@@ -16,18 +16,21 @@
package com.google.gson;
+import static org.junit.Assert.assertEquals;
+
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
+import org.junit.Test;
-public final class ObjectTypeAdapterTest extends TestCase {
+public final class ObjectTypeAdapterTest {
private final Gson gson = new GsonBuilder().create();
private final TypeAdapter<Object> adapter = gson.getAdapter(Object.class);
+ @Test
public void testDeserialize() throws Exception {
Map<?, ?> map = (Map<?, ?>) adapter.fromJson("{\"a\":5,\"b\":[1,2,null],\"c\":{\"x\":\"y\"}}");
assertEquals(5.0, map.get("a"));
@@ -36,23 +39,27 @@ public final class ObjectTypeAdapterTest extends TestCase {
assertEquals(3, map.size());
}
+ @Test
public void testSerialize() throws Exception {
Object object = new RuntimeType();
assertEquals("{'a':5,'b':[1,2,null]}", adapter.toJson(object).replace("\"", "'"));
}
+ @Test
public void testSerializeNullValue() throws Exception {
Map<String, Object> map = new LinkedHashMap<>();
map.put("a", null);
assertEquals("{'a':null}", adapter.toJson(map).replace('"', '\''));
}
+ @Test
public void testDeserializeNullValue() throws Exception {
Map<String, Object> map = new LinkedHashMap<>();
map.put("a", null);
assertEquals(map, adapter.fromJson("{\"a\":null}"));
}
+ @Test
public void testSerializeObject() throws Exception {
assertEquals("{}", adapter.toJson(new Object()));
}
@@ -67,6 +74,7 @@ public final class ObjectTypeAdapterTest extends TestCase {
/** Deeply nested JSON arrays should not cause {@link StackOverflowError} */
@SuppressWarnings("unchecked")
+ @Test
public void testDeserializeDeeplyNestedArrays() throws IOException {
int times = 10000;
// [[[ ... ]]]
@@ -87,6 +95,7 @@ public final class ObjectTypeAdapterTest extends TestCase {
/** Deeply nested JSON objects should not cause {@link StackOverflowError} */
@SuppressWarnings("unchecked")
+ @Test
public void testDeserializeDeeplyNestedObjects() throws IOException {
int times = 10000;
// {"a":{"a": ... {"a":null} ... }}