long beforeRequest = System.currentTimeMillis();
long afterRequest;
try (JettyHttpClient client = new JettyHttpClient()) {
// test servlet bound correctly
StringResponse response = client.execute(
preparePost().setUri(requestUri)
.addHeader(USER_AGENT, userAgent)
.addHeader(CONTENT_TYPE, requestContentType)
.addHeader(REFERER, referrer)
.addHeader("X-Airlift-TraceToken", token)
.setBodyGenerator(createStaticBodyGenerator(requestBody, Charsets.UTF_8))
.build(),
createStringResponseHandler());
afterRequest = System.currentTimeMillis();
assertEquals(response.getStatusCode(), responseCode);
assertEquals(response.getBody(), responseBody);
assertEquals(response.getHeader("Content-Type"), responseContentType);
}
finally {
server.stop();
}