final int port = PortMocker.reserve();
final HttpFacade facade =
new HttpFacade(hosts, port, PortMocker.reserve());
try {
facade.listen();
final Response resp =
new JdkRequest(String.format("http://localhost:%d/", port))
.header(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN)
.header(HttpHeaders.ACCEPT_ENCODING, "gzip")
.header(
HttpHeaders.AUTHORIZATION,
String.format(
"Basic %s",
Base64.encodeBase64String("a:b".getBytes())
)
).uri().path("/a").queryParam("all-versions", "")
.back().fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertHeader(HttpHeaders.CONTENT_ENCODING, "gzip");
MatcherAssert.assertThat(
IOUtils.toString(
new GZIPInputStream(
new ByteArrayInputStream(resp.binary())
),
Charsets.UTF_8
),
Matchers.is(body)
);