@@ -127,6 +127,38 @@ public void differentSubdomainWithClientCookie() throws Exception {
127127 }
128128 }
129129
130+ /**
131+ * Check the cookie expires gets overwritten.
132+ *
133+ * @throws Exception if the test fails
134+ */
135+ @ Test
136+ public void updateCookieExpiresWithClientCookie () throws Exception {
137+ final Date date = new Date (System .currentTimeMillis () + 500_000 );
138+ final Map <String , Class <? extends Servlet >> servlets = new HashMap <>();
139+ servlets .put (SetCookieExpires10Servlet .URL , SetCookieExpires10Servlet .class );
140+ servlets .put (SetCookieExpires1000Servlet .URL , SetCookieExpires1000Servlet .class );
141+ startWebServer ("./" , null , servlets );
142+
143+ try (WebClient webClient = getWebClient ()) {
144+ webClient .getCookieManager ().clearCookies ();
145+
146+ final Date expires = new Date (System .currentTimeMillis () + 10_000L );
147+ Cookie cookie = new Cookie ("localhost" , "first" , "1" , null , expires , false , false );
148+ webClient .getCookieManager ().addCookie (cookie );
149+
150+ assertEquals (1 , webClient .getCookieManager ().getCookies ().size ());
151+ cookie = webClient .getCookieManager ().getCookies ().iterator ().next ();
152+ assertFalse ("" + cookie .getExpires (), cookie .getExpires ().after (date ));
153+
154+ webClient .getPage ("http://localhost:" + PORT + SetCookieExpires1000Servlet .URL );
155+ assertEquals (1 , webClient .getCookieManager ().getCookies ().size ());
156+ cookie = webClient .getCookieManager ().getCookies ().iterator ().next ();
157+ assertTrue ("" + cookie .getExpires (), cookie .getExpires ().after (date ));
158+ }
159+ }
160+
161+
130162 /**
131163 * Check the cookie expires gets overwritten.
132164 *
0 commit comments