public class

MockPageContext

extends PageContext
java.lang.Object
   ↳ PageContext
     ↳ org.springframework.mock.web.MockPageContext

Class Overview

Mock implementation of the javax.servlet.jsp.PageContext interface.

Used for testing the web framework; only necessary for testing applications when testing custom JSP tags.

Note: Expects initialization via the constructor rather than via the PageContext.initialize method. Does not support writing to a JspWriter, request dispatching, and handlePageException calls.

Summary

Public Constructors
MockPageContext()
MockPageContext(ServletContext servletContext)
Create new MockPageContext with a default MockHttpServletRequest, MockHttpServletResponse, MockServletConfig.
MockPageContext(ServletContext servletContext, HttpServletRequest request)
Create new MockPageContext with a MockHttpServletResponse, MockServletConfig.
MockPageContext(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response)
Create new MockPageContext with a MockServletConfig.
MockPageContext(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, ServletConfig servletConfig)
Create new MockServletConfig.
Public Methods
Object findAttribute(String name)
void forward(String url)
Object getAttribute(String name)
Object getAttribute(String name, int scope)
Enumeration<String> getAttributeNames()
Enumeration<String> getAttributeNamesInScope(int scope)
int getAttributesScope(String name)
ELContext getELContext()
Exception getException()
ExpressionEvaluator getExpressionEvaluator()
JspWriter getOut()
Object getPage()
ServletRequest getRequest()
ServletResponse getResponse()
ServletConfig getServletConfig()
ServletContext getServletContext()
HttpSession getSession()
VariableResolver getVariableResolver()
void handlePageException(Exception ex)
void handlePageException(Throwable ex)
void include(String url, boolean flush)
void include(String url)
void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)
void release()
void removeAttribute(String name, int scope)
void removeAttribute(String name)
void setAttribute(String name, Object value, int scope)
void setAttribute(String name, Object value)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public MockPageContext ()

public MockPageContext (ServletContext servletContext)

Create new MockPageContext with a default MockHttpServletRequest, MockHttpServletResponse, MockServletConfig.

Parameters
servletContext the ServletContext that the JSP page runs in (only necessary when actually accessing the ServletContext)

public MockPageContext (ServletContext servletContext, HttpServletRequest request)

Create new MockPageContext with a MockHttpServletResponse, MockServletConfig.

Parameters
servletContext the ServletContext that the JSP page runs in
request the current HttpServletRequest (only necessary when actually accessing the request)

public MockPageContext (ServletContext servletContext, HttpServletRequest request, HttpServletResponse response)

Create new MockPageContext with a MockServletConfig.

Parameters
servletContext the ServletContext that the JSP page runs in
request the current HttpServletRequest
response the current HttpServletResponse (only necessary when actually writing to the response)

public MockPageContext (ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, ServletConfig servletConfig)

Create new MockServletConfig.

Parameters
servletContext the ServletContext that the JSP page runs in
request the current HttpServletRequest
response the current HttpServletResponse
servletConfig the ServletConfig (hardly ever accessed from within a tag)

Public Methods

public Object findAttribute (String name)

public void forward (String url)

Throws
IOException
ServletException

public Object getAttribute (String name)

public Object getAttribute (String name, int scope)

public Enumeration<String> getAttributeNames ()

public Enumeration<String> getAttributeNamesInScope (int scope)

public int getAttributesScope (String name)

public ELContext getELContext ()

public Exception getException ()

public ExpressionEvaluator getExpressionEvaluator ()

public JspWriter getOut ()

public Object getPage ()

public ServletRequest getRequest ()

public ServletResponse getResponse ()

public ServletConfig getServletConfig ()

public ServletContext getServletContext ()

public HttpSession getSession ()

public VariableResolver getVariableResolver ()

public void handlePageException (Exception ex)

Throws
IOException
ServletException

public void handlePageException (Throwable ex)

Throws
IOException
ServletException

public void include (String url, boolean flush)

Throws
IOException
ServletException

public void include (String url)

Throws
IOException
ServletException

public void initialize (Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)

public void release ()

public void removeAttribute (String name, int scope)

public void removeAttribute (String name)

public void setAttribute (String name, Object value, int scope)

public void setAttribute (String name, Object value)