@@ -112,7 +112,7 @@ public void testCookieWithBlankName() throws Exception {
112112 }
113113
114114 /**
115- * Test parsing a cookie with whitespace.
115+ * Test parsing a cookie with whitespace.
116116 */
117117 @ Test
118118 public void testCookieWithWhitespace () throws Exception {
@@ -200,7 +200,7 @@ public void testCookieWithSameSite() throws Exception {
200200 }
201201
202202 /**
203- * Test parsing a cookie with SameSite=Lax.
203+ * Test parsing a cookie with SameSite=Lax.
204204 */
205205 @ Test
206206 public void testCookieWithSameSiteLax () throws Exception {
@@ -212,7 +212,7 @@ public void testCookieWithSameSiteLax() throws Exception {
212212 }
213213
214214 /**
215- * Test parsing a cookie with SameSite=None.
215+ * Test parsing a cookie with SameSite=None.
216216 */
217217 @ Test
218218 public void testCookieWithSameSiteNone () throws Exception {
@@ -285,6 +285,31 @@ public void testCookieWithMaxAgeNegative() throws Exception {
285285 assertNull (cookie .getExpires ());
286286 }
287287
288+ /**
289+ * Test parsing a cookie with max-age more than 400 days.
290+ */
291+ @ Test
292+ public void testCookieWithMaxAgeTooBig () throws Exception {
293+ final String moreThan400Days = "" + ((400 * 24 * 60 * 60 ) + 60 );
294+ final List <Cookie > cookies = parseCookie ("name=value; max-age=" + moreThan400Days );
295+
296+ assertEquals (1 , cookies .size ());
297+ final Cookie cookie = cookies .get (0 );
298+ assertNotNull (cookie .getExpires ());
299+ }
300+
301+ /**
302+ * Test parsing a cookie with max-age that does not fit into an integer
303+ */
304+ @ Test
305+ public void testCookieWithMaxAgeLong () throws Exception {
306+ final List <Cookie > cookies = parseCookie ("name=value; max-age=99999999999" );
307+
308+ assertEquals (1 , cookies .size ());
309+ final Cookie cookie = cookies .get (0 );
310+ assertNotNull (cookie .getExpires ());
311+ }
312+
288313 /**
289314 * Test parsing a cookie with all attributes.
290315 */
@@ -462,7 +487,7 @@ public void testCookieWithVersion() throws Exception {
462487 }
463488
464489 /**
465- * Test parsing cookie with invalid max-age.
490+ * Test parsing cookie with invalid max-age.
466491 */
467492 @ Test
468493 public void testCookieWithInvalidMaxAge () {
0 commit comments