@throws Exception if an error occurs
()
| 322 | * @throws Exception if an error occurs |
| 323 | */ |
| 324 | @Test |
| 325 | public void timeout() throws Exception { |
| 326 | final Map<String, Class<? extends Servlet>> servlets = new HashMap<>(); |
| 327 | servlets.put("/*", DelayDeliverServlet.class); |
| 328 | startWebServer("./", servlets); |
| 329 | |
| 330 | final WebClient client = getWebClient(); |
| 331 | client.getOptions().setTimeout(500); |
| 332 | |
| 333 | try { |
| 334 | client.getPage(URL_FIRST); |
| 335 | fail("timeout expected!"); |
| 336 | } |
| 337 | catch (final SocketTimeoutException e) { |
| 338 | // as expected |
| 339 | } |
| 340 | |
| 341 | // now configure higher timeout allowing to get the page |
| 342 | client.getOptions().setTimeout(5000); |
| 343 | client.getPage(URL_FIRST); |
| 344 | } |
| 345 | |
| 346 | /** |
| 347 | * Make sure cookies set for the request are overwriting the cookieManager. |
no test coverage detected