/** * Override if you wish to customize the HttpServletResponse used in this request. * You may find {@link HttpServletResponseWrapper} useful. */ protected HttpServletResponse createResponse() { return new MockHttpServletResponse(); }
@Deprecated public String encodeUrl(String arg0) { return encodeURL(arg0); }
public MockExternalContext(ServletContext context, HttpServletRequest request) { this.context = context; this.request = request; this.response = new MockHttpServletResponse(); }
public MockExternalContext(ServletContext context, HttpSession session) { this.context = context; this.request = new MockHttpServletRequest(session); this.response = new MockHttpServletResponse(); }
public MockExternalContext(ServletContext context) { this.context = context; this.request = new MockHttpServletRequest(new MockHttpSession(context)); this.response = new MockHttpServletResponse(); }
public MockExternalContext() { this.context = new MockServletContext(); this.request = new MockHttpServletRequest(new MockHttpSession(context)); this.response = new MockHttpServletResponse(); }
private void init() { if (FacesContext.getCurrentInstance() != null) { request = new MockHttpServletRequest(HttpSessionManager.instance(), FacesContext.getCurrentInstance().getExternalContext()); } else { request = new MockHttpServletRequest(HttpSessionManager.instance()); } response = new MockHttpServletResponse(); setContextClassLoader(); // Generate the FacesContext from the JSF FacesContextFactory originalFacesContext = FacesContext.getCurrentInstance(); facesContext = RendererFacesContextFactory.instance().getFacesContext(request, response); DelegatingFacesContext.setCurrentInstance(facesContext); // Create the viewRoot UIViewRoot newRoot = facesContext.getApplication().getViewHandler().createView(facesContext, viewId); facesContext.setViewRoot(newRoot); // Set the responseWriter to write to a buffer writer = new StringWriter(); facesContext.setResponseWriter(facesContext.getRenderKit().createResponseWriter(writer, null, null)); }