* @throws IOException If something goes wrong.
* @throws TemplateException If something goes wrong.
*/
@Test
public void testExecuteSession() throws TemplateException, IOException {
ImportAttributeModel tModel = createMock(ImportAttributeModel.class);
ImportAttributeFMModel fmModel = new ImportAttributeFMModel(tModel);
TilesContainer container = createMock(TilesContainer.class);
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpSession session = createMock(HttpSession.class);
expect(request.getSession()).andReturn(session).times(2);
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(null);
request.setAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
session.setAttribute("one", "value1");
session.setAttribute("two", "value2");
replay(request, session);
HttpRequestHashModel requestModel = new HttpRequestHashModel(request, objectWrapper);
GenericServlet servlet = createMock(GenericServlet.class);
ServletContext servletContext = createMock(ServletContext.class);
expect(servlet.getServletContext()).andReturn(servletContext).times(2);
expect(servletContext.getAttribute(TilesAccess.CONTAINER_ATTRIBUTE)).andReturn(container);
replay(servlet, servletContext);
ServletContextHashModel servletContextModel = new ServletContextHashModel(servlet, objectWrapper);
expect(model.get(FreemarkerServlet.KEY_REQUEST)).andReturn(requestModel).times(CALL_COUNT);
expect(model.get(FreemarkerServlet.KEY_APPLICATION)).andReturn(servletContextModel);
initEnvironment();
TemplateDirectiveBody body = createMock(TemplateDirectiveBody.class);
Map<String, Object> params = new HashMap<String, Object>();
Attribute attribute = createMock(Attribute.class);
params.put("name", objectWrapper.wrap("myName"));
params.put("toName", objectWrapper.wrap("myToName"));
params.put("ignore", objectWrapper.wrap(false));
params.put("scope", objectWrapper.wrap("session"));
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("one", "value1");
attributes.put("two", "value2");
expect(tModel.getImportedAttributes(container, "myName", "myToName",
false, env)).andReturn(attributes);
replay(tModel, body, container, attribute);
fmModel.execute(env, params, null, body);
verify(template, model, request, session, tModel, body, container, servlet, servletContext, attribute);