@@ -172,16 +172,25 @@ public void updateCookieExpires() throws Exception {
172172 servlets .put (SetCookieExpires1000Servlet .URL , SetCookieExpires1000Servlet .class );
173173 startWebServer ("./" , null , servlets );
174174
175- final WebClient webClient = getWebClient ();
176- webClient .getPage ("http://localhost:" + PORT + SetCookieExpires10Servlet .URL );
177- assertEquals (1 , webClient .getCookieManager ().getCookies ().size ());
178- Cookie cookie = webClient .getCookieManager ().getCookies ().iterator ().next ();
179- assertFalse ("" + cookie .getExpires (), cookie .getExpires ().after (date ));
180-
181- webClient .getPage ("http://localhost:" + PORT + SetCookieExpires1000Servlet .URL );
182- assertEquals (1 , webClient .getCookieManager ().getCookies ().size ());
183- cookie = webClient .getCookieManager ().getCookies ().iterator ().next ();
184- assertTrue ("" + cookie .getExpires (), cookie .getExpires ().after (date ));
175+ try (WebClient webClient = getWebClient ()) {
176+ webClient .getPage ("http://localhost:" + PORT + SetCookieExpires10Servlet .URL );
177+ assertEquals (1 , webClient .getCookieManager ().getCookies ().size ());
178+ Cookie cookie = webClient .getCookieManager ().getCookies ().iterator ().next ();
179+ assertFalse ("" + cookie .getExpires (), cookie .getExpires ().after (date ));
180+
181+ webClient .getPage ("http://localhost:" + PORT + SetCookieExpires1000Servlet .URL );
182+ assertEquals (1 , webClient .getCookieManager ().getCookies ().size ());
183+ cookie = webClient .getCookieManager ().getCookies ().iterator ().next ();
184+ assertTrue ("" + cookie .getExpires (), cookie .getExpires ().after (date ));
185+ }
186+ }
187+
188+ @ Override
189+ protected WebClient getWebClient () {
190+ final WebClient webClient = super .getWebClient ();
191+ // set timeout to fail fast when the url not mapped
192+ webClient .getOptions ().setTimeout (1000 );
193+ return webClient ;
185194 }
186195
187196 /**
0 commit comments