@Test
public void testUnknownLengthContentToString() throws Exception {

    final byte[] bytes = "Message content".getBytes(StandardCharsets.ISO_8859_1);
    final BasicHttpEntity entity = new BasicHttpEntity(new ByteArrayInputStream(bytes), -1, null);
    final String s = EntityUtils.toString(entity, "ISO-8859-1");
    Assert.assertEquals("Message content", s);
}