Search in sources :

Example 6 with SessionFlashMapManager

use of org.springframework.web.servlet.support.SessionFlashMapManager in project spring-framework by spring-projects.

the class MockHttpServletRequestBuilder method getFlashMapManager.

private FlashMapManager getFlashMapManager(MockHttpServletRequest request) {
    FlashMapManager flashMapManager = null;
    try {
        ServletContext servletContext = request.getServletContext();
        WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
        flashMapManager = wac.getBean(DispatcherServlet.FLASH_MAP_MANAGER_BEAN_NAME, FlashMapManager.class);
    } catch (IllegalStateException ex) {
    // ignore
    } catch (NoSuchBeanDefinitionException ex) {
    // ignore
    }
    return (flashMapManager != null ? flashMapManager : new SessionFlashMapManager());
}
Also used : SessionFlashMapManager(org.springframework.web.servlet.support.SessionFlashMapManager) FlashMapManager(org.springframework.web.servlet.FlashMapManager) ServletContext(javax.servlet.ServletContext) SessionFlashMapManager(org.springframework.web.servlet.support.SessionFlashMapManager) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Aggregations

SessionFlashMapManager (org.springframework.web.servlet.support.SessionFlashMapManager)6 FlashMap (org.springframework.web.servlet.FlashMap)4 BeforeEach (org.junit.jupiter.api.BeforeEach)2 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)2 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)2 ServletContext (jakarta.servlet.ServletContext)1 ServletContext (javax.servlet.ServletContext)1 Test (org.junit.jupiter.api.Test)1 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)1 DefaultFormattingConversionService (org.springframework.format.support.DefaultFormattingConversionService)1 FormattingConversionService (org.springframework.format.support.FormattingConversionService)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockServletContext (org.springframework.mock.web.MockServletContext)1 Validator (org.springframework.validation.Validator)1 ContentNegotiationManager (org.springframework.web.accept.ContentNegotiationManager)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1 FlashMapManager (org.springframework.web.servlet.FlashMapManager)1 RequestMappingHandlerAdapter (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter)1 RequestMappingHandlerMapping (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping)1 ResourceUrlProvider (org.springframework.web.servlet.resource.ResourceUrlProvider)1