Integration test for long serialization policy.
This commit is contained in:
parent
194c18d20c
commit
cc5cbe5a1f
|
@ -36,6 +36,14 @@ public class LongSerializationPolicyTest extends TestCase {
|
||||||
assertEquals(1556L, element.getAsLong());
|
assertEquals(1556L, element.getAsLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDefaultLongSerializationIntegration() {
|
||||||
|
Gson gson = new GsonBuilder()
|
||||||
|
.setLongSerializationPolicy(LongSerializationPolicy.DEFAULT)
|
||||||
|
.create();
|
||||||
|
assertEquals("[1]", gson.toJson(new long[] { 1L }, long[].class));
|
||||||
|
assertEquals("[1]", gson.toJson(new Long[] { 1L }, Long[].class));
|
||||||
|
}
|
||||||
|
|
||||||
public void testStringLongSerialization() throws Exception {
|
public void testStringLongSerialization() throws Exception {
|
||||||
JsonElement element = LongSerializationPolicy.STRING.serialize(1556L);
|
JsonElement element = LongSerializationPolicy.STRING.serialize(1556L);
|
||||||
assertTrue(element.isJsonPrimitive());
|
assertTrue(element.isJsonPrimitive());
|
||||||
|
@ -45,4 +53,12 @@ public class LongSerializationPolicyTest extends TestCase {
|
||||||
assertTrue(jsonPrimitive.isString());
|
assertTrue(jsonPrimitive.isString());
|
||||||
assertEquals("1556", element.getAsString());
|
assertEquals("1556", element.getAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testStringLongSerializationIntegration() {
|
||||||
|
Gson gson = new GsonBuilder()
|
||||||
|
.setLongSerializationPolicy(LongSerializationPolicy.STRING)
|
||||||
|
.create();
|
||||||
|
assertEquals("[\"1\"]", gson.toJson(new long[] { 1L }, long[].class));
|
||||||
|
assertEquals("[\"1\"]", gson.toJson(new Long[] { 1L }, Long[].class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user