List of usage examples for org.apache.http.util EntityUtils toString
public static String toString(HttpEntity httpEntity, String str) throws IOException, ParseException
From source file:com.seleritycorp.common.base.http.client.FileHttpClientTest.java
@Test public void testExecuteGetOk() throws Exception { Path tmpFile = this.createTempFile(); this.writeFile(tmpFile, "foo\nbar"); replayAll();/*from w ww . j a v a 2 s . c o m*/ HttpClient httpClient = createFileHttpClient(); HttpGet method = new HttpGet(tmpFile.toUri()); org.apache.http.HttpResponse response = httpClient.execute(method); HttpEntity entity = response.getEntity(); verifyAll(); assertThat(response.getStatusLine().getProtocolVersion().getProtocol()).isEqualTo("FILE"); assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); assertThat(response.getStatusLine().getReasonPhrase()).isEqualTo("OK"); assertThat(entity).isNotNull(); assertThat(entity.getContentEncoding()).isNull(); assertThat(entity.getContentType()).isNull(); String body = EntityUtils.toString(entity, StandardCharsets.UTF_8); assertThat(body).isEqualTo("foo\nbar"); }