|
|||||||||
| Home >> All >> com >> meterware >> [ servletunit overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.meterware.servletunit
Class InvocationContextImpl

java.lang.Objectcom.meterware.servletunit.InvocationContextImpl
- All Implemented Interfaces:
- InvocationContext
- class InvocationContextImpl
- extends java.lang.Object
- implements InvocationContext
- extends java.lang.Object
This class represents the context in which a specific servlet request is being made. It contains the objects needed to unit test the methods of a servlet.
| Nested Class Summary | |
(package private) class |
InvocationContextImpl.AccessDeniedException
|
(package private) static class |
InvocationContextImpl.ExecutionContext
|
(package private) static class |
InvocationContextImpl.FilterContext
|
| Field Summary | |
private WebApplication |
_application
|
private ServletUnitClient |
_client
|
private java.util.Stack |
_contextStack
|
private java.net.URL |
_effectiveURL
|
private com.meterware.httpunit.FrameSelector |
_frame
|
private com.meterware.httpunit.WebResponse |
_webResponse
|
| Constructor Summary | |
(package private) |
InvocationContextImpl(ServletUnitClient client,
ServletRunner runner,
com.meterware.httpunit.FrameSelector frame,
com.meterware.httpunit.WebRequest request,
java.util.Dictionary clientHeaders,
byte[] messageBody)
Constructs a servlet invocation context for a specified servlet container, request, and cookie headers. |
| Method Summary | |
private java.net.URL |
computeEffectiveUrl(javax.servlet.http.HttpServletRequest request,
java.net.URL requestURL)
|
private InvocationContextImpl.ExecutionContext |
getContext()
|
javax.servlet.Filter |
getFilter()
Returns the current active filter object. |
javax.servlet.FilterChain |
getFilterChain()
Returns the current filter chain. |
com.meterware.httpunit.FrameSelector |
getFrame()
Returns the target frame for the original request. |
javax.servlet.http.HttpServletRequest |
getRequest()
Returns the request to be processed by the servlet or filter. |
javax.servlet.http.HttpServletResponse |
getResponse()
Returns the response which the servlet or filter should modify during its operation. |
javax.servlet.Servlet |
getServlet()
Returns the selected servlet, initialized to provide access to sessions and servlet context information. |
com.meterware.httpunit.WebResponse |
getServletResponse()
Returns the final response from the servlet. |
boolean |
isFilterActive()
Returns true if the current context is a filter, rather than a servlet. |
void |
popRequest()
Removes the top request dispatcher or filter from this context. |
void |
pushFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
Pushes the current filter onto the execution stack and switches to the next filter or the selected servlet. |
void |
pushForwardRequest(javax.servlet.RequestDispatcher rd,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Adds a request dispatcher to this context to simulate a forward request. |
void |
pushIncludeRequest(javax.servlet.RequestDispatcher rd,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Adds a request dispatcher to this context to simulate an include request. |
void |
service()
Invokes the current servlet or filter. |
private boolean |
userIsAuthorized(javax.servlet.http.HttpServletRequest request,
java.net.URL requestURL)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
_contextStack
private java.util.Stack _contextStack
_effectiveURL
private java.net.URL _effectiveURL
_client
private ServletUnitClient _client
_application
private WebApplication _application
_frame
private com.meterware.httpunit.FrameSelector _frame
_webResponse
private com.meterware.httpunit.WebResponse _webResponse
| Constructor Detail |
InvocationContextImpl
InvocationContextImpl(ServletUnitClient client, ServletRunner runner, com.meterware.httpunit.FrameSelector frame, com.meterware.httpunit.WebRequest request, java.util.Dictionary clientHeaders, byte[] messageBody) throws java.io.IOException, java.net.MalformedURLException
- Constructs a servlet invocation context for a specified servlet container,
request, and cookie headers.
| Method Detail |
getRequest
public javax.servlet.http.HttpServletRequest getRequest()
- Returns the request to be processed by the servlet or filter.
- Specified by:
getRequestin interfaceInvocationContext
getResponse
public javax.servlet.http.HttpServletResponse getResponse()
- Returns the response which the servlet or filter should modify during its operation.
- Specified by:
getResponsein interfaceInvocationContext
service
public void service()
throws javax.servlet.ServletException,
java.io.IOException
- Invokes the current servlet or filter.
- Specified by:
servicein interfaceInvocationContext
getServlet
public javax.servlet.Servlet getServlet() throws javax.servlet.ServletException
- Returns the selected servlet, initialized to provide access to sessions
and servlet context information.
- Specified by:
getServletin interfaceInvocationContext
getServletResponse
public com.meterware.httpunit.WebResponse getServletResponse() throws java.io.IOException
- Returns the final response from the servlet. Note that this method should
only be invoked after all processing has been done to the servlet response.
- Specified by:
getServletResponsein interfaceInvocationContext
getFrame
public com.meterware.httpunit.FrameSelector getFrame()
- Description copied from interface:
InvocationContext - Returns the target frame for the original request.
- Specified by:
getFramein interfaceInvocationContext
pushIncludeRequest
public void pushIncludeRequest(javax.servlet.RequestDispatcher rd, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
- Description copied from interface:
InvocationContext - Adds a request dispatcher to this context to simulate an include request.
- Specified by:
pushIncludeRequestin interfaceInvocationContext
pushForwardRequest
public void pushForwardRequest(javax.servlet.RequestDispatcher rd, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
- Description copied from interface:
InvocationContext - Adds a request dispatcher to this context to simulate a forward request.
- Specified by:
pushForwardRequestin interfaceInvocationContext
popRequest
public void popRequest()
- Description copied from interface:
InvocationContext - Removes the top request dispatcher or filter from this context.
- Specified by:
popRequestin interfaceInvocationContext
isFilterActive
public boolean isFilterActive()
- Description copied from interface:
InvocationContext - Returns true if the current context is a filter, rather than a servlet.
- Specified by:
isFilterActivein interfaceInvocationContext
getFilter
public javax.servlet.Filter getFilter() throws javax.servlet.ServletException
- Description copied from interface:
InvocationContext - Returns the current active filter object. Only valid to call if
InvocationContext.isFilterActive()55 returns true.- Specified by:
getFilterin interfaceInvocationContext
getFilterChain
public javax.servlet.FilterChain getFilterChain()
- Description copied from interface:
InvocationContext - Returns the current filter chain. Only valid to call if
InvocationContext.isFilterActive()55 returns true.- Specified by:
getFilterChainin interfaceInvocationContext
pushFilter
public void pushFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
- Description copied from interface:
InvocationContext - Pushes the current filter onto the execution stack and switches to the next filter or the selected servlet.
This can be used to simulate the effect of the doFilter 55 call.
Note: this method specifies javax.servlet.ServletRequest and javax.servlet.ServletResponse because those are the types passed to Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)>Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)55 ; however, HttpUnit requires the objects to implement javax.servlet.http.HttpServletRequest and javax.servlet.http.HttpServletResponse because they will eventually be passed to an javax.servlet.http.HttpServlet.- Specified by:
pushFilterin interfaceInvocationContext
computeEffectiveUrl
private java.net.URL computeEffectiveUrl(javax.servlet.http.HttpServletRequest request, java.net.URL requestURL)
userIsAuthorized
private boolean userIsAuthorized(javax.servlet.http.HttpServletRequest request, java.net.URL requestURL)
getContext
private InvocationContextImpl.ExecutionContext getContext()
|
|||||||||
| Home >> All >> com >> meterware >> [ servletunit overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.meterware.servletunit.InvocationContextImpl