@Test
public void testKnownLengthContentToString() throws Exception {

    final byte[] bytes = "Message content".getBytes(StandardCharsets.ISO_8859_1);
    final BasicHttpEntity entity = new BasicHttpEntity(new ByteArrayInputStream(bytes), bytes.length,
            ContentType.TEXT_PLAIN.withCharset(StandardCharsets.ISO_8859_1));
    final String s = EntityUtils.toString(entity, StandardCharsets.ISO_8859_1);
    Assert.assertEquals("Message content", s);
}