private static String assert200Ok( CloseableHttpResponse res, String expectedContentType, String expectedContent) throws Exception { assertStatusLine(res, "HTTP/1.1 200 OK"); // Ensure that the 'Last-Modified' header exists and is well-formed. final String lastModified; assertThat(res.containsHeader(HttpHeaders.LAST_MODIFIED), is(true)); lastModified = res.getFirstHeader(HttpHeaders.LAST_MODIFIED).getValue(); HttpHeaderDateFormat.get().parse(lastModified); // Ensure the content and its type are correct. assertThat(EntityUtils.toString(res.getEntity()), is(expectedContent)); assertThat(res.containsHeader(HttpHeaders.CONTENT_TYPE), is(true)); assertThat( res.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue(), startsWith(expectedContentType)); return lastModified; }
private static String currentHttpDate() { return HttpHeaderDateFormat.get().format(new Date()); }