}
}
public void testKnownLengthContentToByteArray() throws Exception {
byte[] bytes = "Message content".getBytes("ISO-8859-1");
BasicHttpEntity httpentity = new BasicHttpEntity();
httpentity.setContent(new ByteArrayInputStream(bytes));
httpentity.setContentLength(bytes.length);
byte[] bytes2 = EntityUtils.toByteArray(httpentity);
assertNotNull(bytes2);
assertEquals(bytes.length, bytes2.length);
for (int i = 0; i < bytes.length; i++) {
assertEquals(bytes[i], bytes2[i]);