byte[] content = new byte[] {1, 2, 3, 4, 5};
ByteArrayEntity entity = new ByteArrayEntity(content);
SessionOutputBufferMockup datatransmitter = new SessionOutputBufferMockup();
HttpMessage message = new HttpMessageMockup();
message.addHeader("Content-Length", Integer.toString(content.length));
EntitySerializer entitywriter = new EntitySerializer(
new StrictContentLengthStrategy());
entitywriter.serialize(datatransmitter, message, entity);