{
CustomContentExchange httpExchange = new CustomContentExchange();
httpExchange.setURL(_scheme + "localhost:" + _port);
httpExchange.setMethod(HttpMethods.POST);
httpExchange.setRequestContent(new ByteArrayBuffer("<h1>??</h1>"));
// let's use the default timeout - the one set on the HttpClient
// (500 ms)
_httpClient.send(httpExchange);
httpExchange.getDoneLatch().await(900,TimeUnit.MILLISECONDS);
// we should get a timeout - the server sleeps for 700 ms
Assert.assertTrue(httpExchange.isTimeoutOccurred());
Assert.assertFalse(httpExchange.isResponseReceived());
// let's do it again - with a custom timeout
httpExchange = new CustomContentExchange();
httpExchange.setURL(_scheme + "localhost:" + _port);
httpExchange.setMethod(HttpMethods.POST);
httpExchange.setRequestContent(new ByteArrayBuffer("<h1>??</h1>"));
httpExchange.setTimeout(500);
// let's use a custom timeout - 500 ms (the default one) + 500 ms
// delay = 1000 ms
_httpClient.send(httpExchange);