@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);
}