|
14 | 14 | import java.util.HashMap; |
15 | 15 | import java.util.Map; |
16 | 16 |
|
17 | | -import static org.hamcrest.Matchers.equalTo; |
18 | | -import static org.hamcrest.Matchers.is; |
| 17 | +import static org.hamcrest.Matchers.*; |
19 | 18 | import static org.junit.Assert.assertThat; |
20 | 19 |
|
21 | 20 | public class PayloadSerializerTest { |
@@ -117,6 +116,26 @@ public void shouldSerializeCustomDateInSeconds() throws Exception { |
117 | 116 | assertThat(writer.toString(), is(equalTo("{\"birthdate\":1478874}"))); |
118 | 117 | } |
119 | 118 |
|
| 119 | + @Test |
| 120 | + public void shouldSerializeDatesUsingLong() throws Exception { |
| 121 | + long secs = Integer.MAX_VALUE + 10000L; |
| 122 | + Date date = new Date(secs * 1000L); |
| 123 | + Map<String, Object> claims = new HashMap<String, Object>(); |
| 124 | + claims.put("iat", date); |
| 125 | + claims.put("nbf", date); |
| 126 | + claims.put("exp", date); |
| 127 | + claims.put("ctm", date); |
| 128 | + ClaimsHolder holder = new ClaimsHolder(claims); |
| 129 | + serializer.serialize(holder, jsonGenerator, serializerProvider); |
| 130 | + jsonGenerator.flush(); |
| 131 | + |
| 132 | + String json = writer.toString(); |
| 133 | + assertThat(json, containsString("\"iat\":2147493647")); |
| 134 | + assertThat(json, containsString("\"nbf\":2147493647")); |
| 135 | + assertThat(json, containsString("\"exp\":2147493647")); |
| 136 | + assertThat(json, containsString("\"ctm\":2147493647")); |
| 137 | + } |
| 138 | + |
120 | 139 | @Test |
121 | 140 | public void shouldSerializeStrings() throws Exception { |
122 | 141 | ClaimsHolder holder = holderFor("name", "Auth0 Inc"); |
|
0 commit comments