FreemarkerRequest extends AbstractViewRequest { public static FreemarkerRequest createServletFreemarkerRequest( ApplicationContext applicationContext, Environment env) { HttpRequestHashModel requestModel = FreemarkerRequestUtil .getRequestHashModel(env); HttpServletRequest request = requestModel.getRequest(); HttpServletResponse response = requestModel.getResponse(); DispatchRequest enclosedRequest = new ServletRequest( applicationContext, request, response); return new FreemarkerRequest(enclosedRequest, env); } FreemarkerRequest(DispatchRequest enclosedRequest,
            Environment env); static FreemarkerRequest createServletFreemarkerRequest(
            ApplicationContext applicationContext, Environment env); Environment getEnvironment(); @Override Locale getRequestLocale(); Map<String, Object> getPageScope(); @Override List<String> getAvailableScopes(); @Override PrintWriter getPrintWriter(); @Override Writer getWriter(); @Override Map<String, Object> getContext(String scope);  }
@Test public void testCreateServletFreemarkerRequest() throws TemplateModelException { Template template = createMock(Template.class); TemplateHashModel model = createMock(TemplateHashModel.class); PrintWriter writer = new PrintWriter(new StringWriter()); HttpServletRequest httpRequest = createMock(HttpServletRequest.class); HttpServletResponse httpResponse = createMock(HttpServletResponse.class); ObjectWrapper objectWrapper = createMock(ObjectWrapper.class); ApplicationContext applicationContext = createMock(ApplicationContext.class); expect(template.getMacros()).andReturn(new HashMap<Object, Object>()); replay(httpRequest, httpResponse, objectWrapper); HttpRequestHashModel requestHashModel = new HttpRequestHashModel(httpRequest, httpResponse, objectWrapper); expect(model.get("Request")).andReturn(requestHashModel); replay(template, model, applicationContext); Environment env = new Environment(template, model, writer); Locale locale = Locale.ITALY; env.setLocale(locale); FreemarkerRequest request = FreemarkerRequest.createServletFreemarkerRequest(applicationContext, env); ServletRequest servletRequest = (ServletRequest) request.getWrappedRequest(); assertEquals(httpRequest, servletRequest.getRequest()); assertEquals(httpResponse, servletRequest.getResponse()); verify(template, model, httpRequest, httpResponse, objectWrapper, applicationContext); }