Adding a few more assert to the InstanceCreatorTest to ensure that the default values are set for sub class fields.

This commit is contained in:
Joel Leitch 2009-10-09 21:23:51 +00:00
parent d87d3f807f
commit 102f8b3a71

View File

@ -16,10 +16,6 @@
package com.google.gson.functional;
import java.lang.reflect.Type;
import junit.framework.TestCase;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.InstanceCreator;
@ -27,6 +23,10 @@ import com.google.gson.common.TestTypes.Base;
import com.google.gson.common.TestTypes.ClassWithBaseField;
import com.google.gson.common.TestTypes.Sub;
import junit.framework.TestCase;
import java.lang.reflect.Type;
/**
* Functional Test exercising custom serialization only. When test applies to both
* serialization and deserialization then add it to CustomTypeAdapterTest.
@ -56,9 +56,14 @@ public class InstanceCreatorTest extends TestCase {
}
})
.create();
String json = "{baseName:'Base',subName:'SubRevised'}";
Base base = gson.fromJson(json, Base.class);
assertFalse("SubRevised".equals(((Sub)base).subName));
assertTrue(base instanceof Sub);
Sub sub = (Sub) base;
assertFalse("SubRevised".equals(sub.subName));
assertEquals(Sub.SUB_NAME, sub.subName);
}
public void testInstanceCreatorReturnsSubTypeForField() {