@Override public final byte[] binary() { return this.response.binary(); }
/** * Assume the payload is Text and do some assertions based on the configuration in the REST * Test. * * @param restTest * @param response */ private void assertTextPayload(RestTest restTest, com.jcabi.http.Response response) { InputStream inputStream = null; try { inputStream = new ByteArrayInputStream(response.binary()); List<String> lines = IOUtils.readLines(inputStream); StringBuilder builder = new StringBuilder(); for (String line : lines) { builder.append(line).append("\n"); } String actual = builder.toString(); String expected = restTest.getExpectedResponsePayload(); if (expected != null) { Assert.assertEquals("Response payload (text/plain) mismatch.", expected, actual); } } catch (Exception e) { throw new Error(e); } finally { IOUtils.closeQuietly(inputStream); } }
new RsWithBody( new RsWithHeaders(hdrs), rsp.binary() ), rsp.status(),
InputStream inputStream = null; try { inputStream = new ByteArrayInputStream(response.binary()); ObjectMapper jacksonParser = new ObjectMapper(); JsonNode actualJson = jacksonParser.readTree(inputStream);
new RsWithBody( new RsWithHeaders(hdrs), rsp.binary() ), rsp.status(),
@Override public InputStream read() throws IOException { return new ByteArrayInputStream( this.request.fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(XmlResponse.class) .rel(this.xpath("links/link[@rel='download']/@href")) .fetch().binary() ); }
InputStream inputStream = null; try { inputStream = new ByteArrayInputStream(response.binary()); StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer);