public void testEntitySerialization() throws Exception {
byte[] content = new byte[] {1, 2, 3, 4, 5};
ByteArrayEntity entity = new ByteArrayEntity(content);
HttpDataTransmitterMockup datatransmitter = new HttpDataTransmitterMockup();
HttpMessage message = new HttpMessageMockup();
message.addHeader("Content-Length", Integer.toString(content.length));
EntitySerializer entitywriter = new EntitySerializer(
new StrictContentLengthStrategy());
entitywriter.serialize(datatransmitter, message, entity);
byte[] data = datatransmitter.getData();
assertNotNull(data);
assertEquals(content.length, data.length);
}