Search in sources :

Example 1 with AbstractCasView

use of org.apereo.cas.services.web.view.AbstractCasView in project cas by apereo.

the class Cas30ResponseViewTests method renderView.

protected Map<?, ?> renderView() throws Exception {
    final ModelAndView modelAndView = this.getModelAndViewUponServiceValidationWithSecurePgtUrl();
    LOGGER.debug("Retrieved model and view [{}]", modelAndView.getModel());
    final MockHttpServletRequest req = new MockHttpServletRequest(new MockServletContext());
    req.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, new GenericWebApplicationContext(req.getServletContext()));
    final ProtocolAttributeEncoder encoder = new DefaultCasProtocolAttributeEncoder(this.servicesManager, CipherExecutor.noOpOfStringToString());
    final View viewDelegated = new View() {

        @Override
        public String getContentType() {
            return MediaType.TEXT_HTML_VALUE;
        }

        @Override
        public void render(final Map<String, ?> map, final HttpServletRequest request, final HttpServletResponse response) {
            LOGGER.warn("Setting attribute [{}]", map.keySet());
            map.forEach(request::setAttribute);
        }
    };
    final AbstractCasView view = getCasViewToRender(encoder, viewDelegated);
    final MockHttpServletResponse resp = new MockHttpServletResponse();
    view.render(modelAndView.getModel(), req, resp);
    return getRenderedViewModelMap(req);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ModelAndView(org.springframework.web.servlet.ModelAndView) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) AbstractCasView(org.apereo.cas.services.web.view.AbstractCasView) ModelAndView(org.springframework.web.servlet.ModelAndView) View(org.springframework.web.servlet.View) MockServletContext(org.springframework.mock.web.MockServletContext) HttpServletRequest(javax.servlet.http.HttpServletRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DefaultCasProtocolAttributeEncoder(org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder) DefaultCasProtocolAttributeEncoder(org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder) ProtocolAttributeEncoder(org.apereo.cas.authentication.ProtocolAttributeEncoder) GenericWebApplicationContext(org.springframework.web.context.support.GenericWebApplicationContext) Map(java.util.Map) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) AbstractCasView(org.apereo.cas.services.web.view.AbstractCasView)

Aggregations

Map (java.util.Map)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ProtocolAttributeEncoder (org.apereo.cas.authentication.ProtocolAttributeEncoder)1 DefaultCasProtocolAttributeEncoder (org.apereo.cas.authentication.support.DefaultCasProtocolAttributeEncoder)1 AbstractCasView (org.apereo.cas.services.web.view.AbstractCasView)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 MockServletContext (org.springframework.mock.web.MockServletContext)1 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 View (org.springframework.web.servlet.View)1