aboutsummaryrefslogtreecommitdiff
path: root/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java')
-rw-r--r--gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java b/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java
index 3ed60327..7a0ecaa2 100644
--- a/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java
+++ b/gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java
@@ -16,6 +16,10 @@
package com.google.gson.functional;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.InstanceCreator;
@@ -28,7 +32,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* Functional Test exercising custom serialization only. When test applies to both
@@ -36,8 +40,9 @@ import junit.framework.TestCase;
*
* @author Inderjeet Singh
*/
-public class InstanceCreatorTest extends TestCase {
+public class InstanceCreatorTest {
+ @Test
public void testInstanceCreatorReturnsBaseType() {
Gson gson = new GsonBuilder()
.registerTypeAdapter(Base.class, new InstanceCreator<Base>() {
@@ -51,6 +56,7 @@ public class InstanceCreatorTest extends TestCase {
assertEquals("BaseRevised", base.baseName);
}
+ @Test
public void testInstanceCreatorReturnsSubTypeForTopLevelObject() {
Gson gson = new GsonBuilder()
.registerTypeAdapter(Base.class, new InstanceCreator<Base>() {
@@ -69,6 +75,7 @@ public class InstanceCreatorTest extends TestCase {
assertEquals(Sub.SUB_NAME, sub.subName);
}
+ @Test
public void testInstanceCreatorReturnsSubTypeForField() {
Gson gson = new GsonBuilder()
.registerTypeAdapter(Base.class, new InstanceCreator<Base>() {
@@ -84,6 +91,7 @@ public class InstanceCreatorTest extends TestCase {
}
// This regressed in Gson 2.0 and 2.1
+ @Test
public void testInstanceCreatorForCollectionType() {
@SuppressWarnings("serial")
class SubArrayList<T> extends ArrayList<T> {}
@@ -101,6 +109,7 @@ public class InstanceCreatorTest extends TestCase {
}
@SuppressWarnings("unchecked")
+ @Test
public void testInstanceCreatorForParametrizedType() throws Exception {
@SuppressWarnings("serial")
class SubTreeSet<T> extends TreeSet<T> {}