* @throws IOException If something goes wrong.
* @throws TemplateException If something goes wrong.
*/
@Test
public void testExecute() throws TemplateException, IOException {
AddAttributeModel tModel = createMock(AddAttributeModel.class);
AddAttributeFMModel fmModel = new AddAttributeFMModel(tModel);
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpRequestHashModel requestModel = new HttpRequestHashModel(request, objectWrapper);
expect(model.get(FreemarkerServlet.KEY_REQUEST)).andReturn(requestModel);
initEnvironment();
TemplateDirectiveBody body = createMock(TemplateDirectiveBody.class);
ArrayStack<Object> composeStack = new ArrayStack<Object>();
Map<String, Object> params = new HashMap<String, Object>();
Integer value = new Integer(1);
params.put("value", objectWrapper.wrap(value));
params.put("expression", objectWrapper.wrap("myExpression"));
params.put("role", objectWrapper.wrap("myRole"));
params.put("type", objectWrapper.wrap("myType"));
expect(request.getAttribute(FreeMarkerUtil.COMPOSE_STACK_ATTRIBUTE_NAME)).andReturn(composeStack);
tModel.start(composeStack);
tModel.end(composeStack, value, "myExpression", "",
"myRole", "myType");
body.render(isA(StringWriter.class));
replay(request, tModel, body);
fmModel.execute(env, params, null, body);