Search in sources :

Example 1 with FreeMarkerViewResolver

use of org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver in project spring-framework by spring-projects.

the class ViewResolverRegistryTests method freeMarkerDefaultValues.

@Test
public void freeMarkerDefaultValues() {
    this.registry.freeMarker();
    FreeMarkerViewResolver resolver = checkAndGetResolver(FreeMarkerViewResolver.class);
    checkPropertyValues(resolver, "prefix", "", "suffix", ".ftl");
}
Also used : FreeMarkerViewResolver(org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver) Test(org.junit.Test)

Example 2 with FreeMarkerViewResolver

use of org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver in project spring-framework by spring-projects.

the class ViewResolverRegistryTests method freeMarker.

@Test
public void freeMarker() {
    this.registry.freeMarker().prefix("/").suffix(".fmt").cache(false);
    FreeMarkerViewResolver resolver = checkAndGetResolver(FreeMarkerViewResolver.class);
    checkPropertyValues(resolver, "prefix", "/", "suffix", ".fmt", "cacheLimit", 0);
}
Also used : FreeMarkerViewResolver(org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver) Test(org.junit.Test)

Example 3 with FreeMarkerViewResolver

use of org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver in project spring-boot by spring-projects.

the class FreeMarkerAutoConfigurationTests method render.

private MockHttpServletResponse render(String viewName) throws Exception {
    FreeMarkerViewResolver resolver = this.context.getBean(FreeMarkerViewResolver.class);
    View view = resolver.resolveViewName(viewName, Locale.UK);
    assertThat(view).isNotNull();
    HttpServletRequest request = new MockHttpServletRequest();
    request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context);
    MockHttpServletResponse response = new MockHttpServletResponse();
    view.render(null, request, response);
    return response;
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) FreeMarkerViewResolver(org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver) View(org.springframework.web.servlet.View) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Aggregations

FreeMarkerViewResolver (org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver)3 Test (org.junit.Test)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 View (org.springframework.web.servlet.View)1