Example usage for org.springframework.web.servlet.view AbstractView DEFAULT_CONTENT_TYPE

List of usage examples for org.springframework.web.servlet.view AbstractView DEFAULT_CONTENT_TYPE

Introduction

In this page you can find the example usage for org.springframework.web.servlet.view AbstractView DEFAULT_CONTENT_TYPE.

Prototype

String DEFAULT_CONTENT_TYPE

To view the source code for org.springframework.web.servlet.view AbstractView DEFAULT_CONTENT_TYPE.

Click Source Link

Document

Default content type.

Usage

From source file:org.hdiv.web.servlet.view.freemarker.FreeMarkerViewTests.java

@Test
public void testValidTemplateName() throws Exception {
    FreeMarkerView fv = new FreeMarkerView();

    MockControl wmc = MockControl.createNiceControl(WebApplicationContext.class);
    WebApplicationContext wac = (WebApplicationContext) wmc.getMock();
    MockServletContext sc = new MockServletContext();

    wac.getBeansOfType(FreeMarkerConfig.class, true, false);
    Map configs = new HashMap();
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    configurer.setConfiguration(new FreeMarkerTestConfiguration());
    configs.put("configurer", configurer);
    wmc.setReturnValue(configs);//w  w  w  .ja va 2 s.com
    wac.getParentBeanFactory();
    wmc.setReturnValue(null);
    wac.getServletContext();
    wmc.setReturnValue(sc, 5);
    wmc.replay();

    fv.setUrl("templateName");
    fv.setApplicationContext(wac);

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addPreferredLocale(Locale.US);
    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
    HttpServletResponse response = new MockHttpServletResponse();

    Map model = new HashMap();
    model.put("myattr", "myvalue");
    fv.render(model, request, response);

    wmc.verify();
    assertEquals(AbstractView.DEFAULT_CONTENT_TYPE, response.getContentType());
}