@Test
public void testCreateRequest() throws IOException, TemplateModelException{
@SuppressWarnings("unchecked")
Map<String, TemplateModel> params = createMock(Map.class);
Template template = createMock(Template.class);
TemplateHashModel rootDataModel = createMock(TemplateHashModel.class);
Writer out = createMock(Writer.class);
TemplateDirectiveBody body = createMock(TemplateDirectiveBody.class);
GenericServlet servlet = createMock(GenericServlet.class);
ObjectWrapper wrapper = createMock(ObjectWrapper.class);
ServletContext servletContext = createMock(ServletContext.class);
ApplicationContext applicationContext = createMock(ApplicationContext.class);
HttpServletRequest httpServletRequest = createMock(HttpServletRequest.class);
HttpServletResponse httpServletResponse = createMock(HttpServletResponse.class);
expect(template.getMacros()).andReturn(new HashMap<String, Macro>());
expect(servlet.getServletContext()).andReturn(servletContext)
.anyTimes();
expect(
servletContext
.getAttribute(ApplicationAccess.APPLICATION_CONTEXT_ATTRIBUTE))
.andReturn(applicationContext);
replay(servlet, wrapper, servletContext, applicationContext,
httpServletRequest, httpServletResponse);
ServletContextHashModel servletContextHashModel = new ServletContextHashModel(
servlet, wrapper);
HttpRequestHashModel httpRequestHashModel = new HttpRequestHashModel(
httpServletRequest, httpServletResponse, wrapper);
expect(rootDataModel.get(FreemarkerServlet.KEY_APPLICATION)).andReturn(
servletContextHashModel);
expect(rootDataModel.get(FreemarkerServlet.KEY_REQUEST)).andReturn(
httpRequestHashModel);
replay(template, rootDataModel, out);
Environment env = new Environment(template, rootDataModel, out);