diff --git a/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java b/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java index eb9107b0..945abeb5 100755 --- a/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java +++ b/gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java @@ -82,6 +82,30 @@ public class NullObjectAndFieldTest extends TestCase { assertTrue(json.contains("\"array\":null")); } + /** + * Added to verify http://code.google.com/p/google-gson/issues/detail?id=68 + */ + public void testNullWrappedPrimitiveMemberSerialization() { + Gson gson = gsonBuilder.serializeNulls().create(); + ClassWithNullWrappedPrimitive target = new ClassWithNullWrappedPrimitive(); + String json = gson.toJson(target); + assertTrue(json.contains("\"value\":null")); + } + + /** + * Added to verify http://code.google.com/p/google-gson/issues/detail?id=68 + */ + public void testNullWrappedPrimitiveMemberDeserialization() { + Gson gson = gsonBuilder.create(); + String json = "{'value':null}"; + ClassWithNullWrappedPrimitive target = gson.fromJson(json, ClassWithNullWrappedPrimitive.class); + assertNull(target.value); + } + + private static class ClassWithNullWrappedPrimitive { + private Long value; + } + public void testExplicitSerializationOfNullCollectionMembers() { Gson gson = gsonBuilder.create(); ClassWithMembers target = new ClassWithMembers(); @@ -119,5 +143,4 @@ public class NullObjectAndFieldTest extends TestCase { return obj; } } - }