@Override public void flush() throws IOException { super.flush(); setCommitted(true); } }
/** * Set a single value for the specified HTTP parameter. * <p>If there are already one or more values registered for the given * parameter name, they will be replaced. */ public void setParameter(String name, String value) { setParameter(name, new String[] {value}); }
/** * Invalidates this session then unbinds any objects bound to it. * @throws IllegalStateException if this method is called on an already invalidated session */ @Override public void invalidate() { assertIsValid(); this.invalid = true; clearAttributes(); }
/** * Create new MockServletConfig. * @param servletContext the ServletContext that the JSP page runs in * @param request the current HttpServletRequest * @param response the current HttpServletResponse * @param servletConfig the ServletConfig (hardly ever accessed from within a tag) */ public MockPageContext(@Nullable ServletContext servletContext, @Nullable HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable ServletConfig servletConfig) { this.servletContext = (servletContext != null ? servletContext : new MockServletContext()); this.request = (request != null ? request : new MockHttpServletRequest(servletContext)); this.response = (response != null ? response : new MockHttpServletResponse()); this.servletConfig = (servletConfig != null ? servletConfig : new MockServletConfig(servletContext)); }
/** * Create a new {@link MockHttpServletRequest} based on the supplied * {@code ServletContext}. * <p>Can be overridden in subclasses. */ protected MockHttpServletRequest createServletRequest(ServletContext servletContext) { return new MockHttpServletRequest(servletContext); }
@Override public RequestPostProcessor beforeMockMvcCreated(ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context) { return request -> { if (this.session != null) { request.setSession(this.session); } return request; }; }
public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) { request.setAttribute(attr, value); return request; } }
private void addHeaderValue(String name, Object value) { if (setSpecialHeader(name, value)) { return; } doAddHeaderValue(name, value, false); }
@Override public void setStatus(int status) { if (!this.isCommitted()) { this.status = status; } }
/** * Invalidate this request, clearing its state. */ public void invalidate() { close(); clearAttributes(); }
@Override public void setContentLengthLong(long contentLength) { this.contentLength = contentLength; doAddHeaderValue(HttpHeaders.CONTENT_LENGTH, contentLength, true); }
@Override public Object evaluate(javax.servlet.jsp.el.VariableResolver variableResolver) throws javax.servlet.jsp.el.ELException { return doEvaluate(expression, expectedType, functionMapper); } };
@Override public void setCharacterEncoding(String characterEncoding) { this.characterEncoding = characterEncoding; this.charset = true; updateContentTypeHeader(); }
public void setSession(HttpSession session) { this.session = session; if (session instanceof MockHttpSession) { MockHttpSession mockSession = ((MockHttpSession) session); mockSession.access(); } }
@Override public long getLastAccessedTime() { assertIsValid(); return this.lastAccessedTime; }
/** * The default implementation delegates to {@link #encodeURL}, * returning the given URL String as-is. * <p>Can be overridden in subclasses, appending a session id or the like * in a redirect-specific fashion. For general URL encoding rules, * override the common {@link #encodeURL} method instead, applying * to redirect URLs as well as to general URLs. */ @Override public String encodeRedirectURL(String url) { return encodeURL(url); }
private void setHeaderValue(String name, Object value) { if (setSpecialHeader(name, value)) { return; } doAddHeaderValue(name, value, true); }
@Override public void setContentLength(int contentLength) { this.contentLength = contentLength; doAddHeaderValue(HttpHeaders.CONTENT_LENGTH, contentLength, true); }
@Override @SuppressWarnings("rawtypes") public Object evaluate(String expression, Class expectedType, javax.servlet.jsp.el.VariableResolver variableResolver, javax.servlet.jsp.el.FunctionMapper functionMapper) throws javax.servlet.jsp.el.ELException { return doEvaluate(expression, expectedType, functionMapper); }