@Test(expected = IOException.class)
public void testEvaluateWriterException() throws TemplateException, IOException {

    TemplateDirectiveBody body = createMock(TemplateDirectiveBody.class);
    Writer writer = createMock(Writer.class);
    body.render(writer);
    expectLastCall().andThrow(new TemplateException(null));
    replay(body, writer);
    try {
        FreemarkerModelBody modelBody = new FreemarkerModelBody(null, body);
        modelBody.evaluate(writer);
    } finally {
        verify(body, writer);
    }
}