### Question:
ApacheHttpRequest extends BaseHttpRequest implements IHttpRequest { @Override public String getRequestBodyFromStream() throws IOException { if (myRequest instanceof HttpEntityEnclosingRequest) { HttpEntity entity = ((HttpEntityEnclosingRequest) myRequest).getEntity(); if (entity.isRepeatable()) { final Header contentTypeHeader = myRequest.getFirstHeader("Content-Type"); Charset charset = contentTypeHeader == null ? null : ContentType.parse(contentTypeHeader.getValue()).getCharset(); return IOUtils.toString(entity.getContent(), charset); } } return null; } ApacheHttpRequest(HttpClient theClient, HttpRequestBase theApacheRequest); @Override void addHeader(String theName, String theValue); @Override IHttpResponse execute(); @Override Map<String, List<String>> getAllHeaders(); HttpRequestBase getApacheRequest(); @Override String getHttpVerbName(); @Override void removeHeaders(String theHeaderName); @Override String getRequestBodyFromStream(); @Override String getUri(); @Override void setUri(String theUrl); @Override String toString();  }### Answer:
@Test public void testGetRequestBodyFromStream() throws IOException { httpEntity = new StringEntity(ENTITY_CONTENT, Charset.forName("ISO-8859-1")); apacheRequest.setHeader("Content-type", "text/plain; charset=ISO-8859-1"); apacheRequest.setEntity(httpEntity); String result = new ApacheHttpRequest(null, apacheRequest).getRequestBodyFromStream(); assertEquals(ENTITY_CONTENT, result); }
@Test public void testGetRequestBodyFromStreamWithDefaultCharset() throws IOException { httpEntity = new StringEntity(ENTITY_CONTENT, Charset.defaultCharset()); apacheRequest.setHeader("Content-type", "text/plain"); apacheRequest.setEntity(httpEntity); String result = new ApacheHttpRequest(null, apacheRequest).getRequestBodyFromStream(); assertEquals(ENTITY_CONTENT, result); }