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