org.springframework.mock.web
Class MockPageContext

java.lang.Object
  extended byjavax.servlet.jsp.JspContext
      extended byjavax.servlet.jsp.PageContext
          extended byorg.springframework.mock.web.MockPageContext

public class MockPageContext
extends PageContext

Mock implementation of the 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.

Since:
1.0.2
Author:
Juergen Hoeller

Field Summary
 
Fields inherited from class javax.servlet.jsp.PageContext
APPLICATION, APPLICATION_SCOPE, CONFIG, EXCEPTION, OUT, PAGE, PAGE_SCOPE, PAGECONTEXT, REQUEST, REQUEST_SCOPE, RESPONSE, SESSION, SESSION_SCOPE
 
Constructor Summary
MockPageContext()
          Create new MockPageContext with a MockServletContext, MockHttpServletRequest, MockHttpServletResponse, MockServletConfig.
MockPageContext(ServletContext servletContext)
          Create new MockPageContext with a 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.
 
Method Summary
 Object findAttribute(String name)
           
 void forward(String url)
           
 Object getAttribute(String name)
           
 Object getAttribute(String name, int scope)
           
 Enumeration getAttributeNames()
           
 Enumeration getAttributeNamesInScope(int scope)
           
 int getAttributesScope(String name)
           
 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)
           
 void include(String url, boolean flush)
           
 void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)
           
 void release()
           
 void removeAttribute(String name)
           
 void removeAttribute(String name, int scope)
           
 void setAttribute(String name, Object value)
           
 void setAttribute(String name, Object value, int scope)
           
 
Methods inherited from class javax.servlet.jsp.PageContext
getErrorData, pushBody
 
Methods inherited from class javax.servlet.jsp.JspContext
popBody, pushBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockPageContext

public MockPageContext()
Create new MockPageContext with a MockServletContext, MockHttpServletRequest, MockHttpServletResponse, MockServletConfig.


MockPageContext

public MockPageContext(ServletContext servletContext)
Create new MockPageContext with a MockHttpServletRequest, MockHttpServletResponse, MockServletConfig.

Parameters:
servletContext - the ServletContext that the servlet runs in (only necessary when accessing the ServletContext)

MockPageContext

public MockPageContext(ServletContext servletContext,
                       HttpServletRequest request)
Create new MockPageContext with a MockHttpServletResponse, MockServletConfig.

Parameters:
servletContext - the ServletContext that the servlet runs in
request - the current HttpServletRequest (only necessary when accessing the request)

MockPageContext

public MockPageContext(ServletContext servletContext,
                       HttpServletRequest request,
                       HttpServletResponse response)
Create new MockPageContext with a MockServletConfig.

Parameters:
servletContext - the ServletContext that the servlet runs in
request - the current HttpServletRequest
response - the current HttpServletResponse (only necessary when writing to the response)

MockPageContext

public MockPageContext(ServletContext servletContext,
                       HttpServletRequest request,
                       HttpServletResponse response,
                       ServletConfig servletConfig)
Create new MockServletConfig.

Parameters:
servletContext - the ServletContext that the servlet runs in
request - the current HttpServletRequest
response - the current HttpServletResponse
servletConfig - the ServletConfig (hardly ever accessed from within a tag)
Method Detail

initialize

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

release

public void release()

setAttribute

public void setAttribute(String name,
                         Object value)

setAttribute

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

getAttribute

public Object getAttribute(String name)

getAttribute

public Object getAttribute(String name,
                           int scope)

findAttribute

public Object findAttribute(String name)

removeAttribute

public void removeAttribute(String name)

removeAttribute

public void removeAttribute(String name,
                            int scope)

getAttributesScope

public int getAttributesScope(String name)

getAttributeNames

public Enumeration getAttributeNames()

getAttributeNamesInScope

public Enumeration getAttributeNamesInScope(int scope)

getOut

public JspWriter getOut()

getExpressionEvaluator

public ExpressionEvaluator getExpressionEvaluator()

getVariableResolver

public VariableResolver getVariableResolver()

getSession

public HttpSession getSession()

getPage

public Object getPage()

getRequest

public ServletRequest getRequest()

getResponse

public ServletResponse getResponse()

getException

public Exception getException()

getServletConfig

public ServletConfig getServletConfig()

getServletContext

public ServletContext getServletContext()

forward

public void forward(String url)
             throws ServletException,
                    IOException
Throws:
ServletException
IOException

include

public void include(String url)
             throws ServletException,
                    IOException
Throws:
ServletException
IOException

include

public void include(String url,
                    boolean flush)
             throws ServletException,
                    IOException
Throws:
ServletException
IOException

handlePageException

public void handlePageException(Exception ex)
                         throws ServletException,
                                IOException
Throws:
ServletException
IOException

handlePageException

public void handlePageException(Throwable ex)
                         throws ServletException,
                                IOException
Throws:
ServletException
IOException


Copyright (C) 2003-2004 The Spring Framework Project.