|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.struts.mock.MockHttpServletRequest
public class MockHttpServletRequest
Mock HttpServletRequest object for low-level unit tests of Struts controller components. Coarser grained tests should be implemented in terms of the Cactus framework, instead of the mock object classes.
WARNING - Only the minimal set of methods needed to
create unit tests is provided, plus additional methods to configure this
object as necessary. Methods for unsupported operations will throw
UnsupportedOperationException.
WARNING - Because unit tests operate in a single threaded environment, no synchronization is performed.
| Field Summary | |
|---|---|
protected java.util.HashMap |
attributes
The set of request attributes. |
protected java.lang.String |
contentType
The Content Type for this request. |
protected java.lang.String |
contextPath
The context path for this request. |
protected java.util.Locale |
locale
The preferred locale for this request. |
protected java.lang.String |
method
The HTTP request method. |
protected java.util.HashMap |
parameters
The set of arrays of parameter values, keyed by parameter name. |
protected java.lang.String |
pathInfo
The extra path information for this request. |
protected java.security.Principal |
principal
The authenticated user for this request. |
protected java.lang.String |
queryString
The query string for this request. |
protected java.lang.String |
servletPath
The servlet path for this request. |
protected javax.servlet.http.HttpSession |
session
The HttpSession with which we are associated. |
| Fields inherited from interface javax.servlet.http.HttpServletRequest |
|---|
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
| Constructor Summary | |
|---|---|
MockHttpServletRequest()
|
|
MockHttpServletRequest(javax.servlet.http.HttpSession session)
|
|
MockHttpServletRequest(java.lang.String contextPath,
java.lang.String servletPath,
java.lang.String pathInfo,
java.lang.String queryString)
|
|
MockHttpServletRequest(java.lang.String contextPath,
java.lang.String servletPath,
java.lang.String pathInfo,
java.lang.String queryString,
javax.servlet.http.HttpSession session)
|
|
| Method Summary | |
|---|---|
void |
addParameter(java.lang.String name,
java.lang.String value)
|
java.lang.Object |
getAttribute(java.lang.String name)
|
java.util.Enumeration |
getAttributeNames()
|
java.lang.String |
getAuthType()
|
java.lang.String |
getCharacterEncoding()
|
int |
getContentLength()
|
java.lang.String |
getContentType()
|
java.lang.String |
getContextPath()
|
javax.servlet.http.Cookie[] |
getCookies()
|
long |
getDateHeader(java.lang.String name)
|
java.lang.String |
getHeader(java.lang.String name)
|
java.util.Enumeration |
getHeaderNames()
|
java.util.Enumeration |
getHeaders(java.lang.String name)
|
javax.servlet.ServletInputStream |
getInputStream()
|
int |
getIntHeader(java.lang.String name)
|
java.util.Locale |
getLocale()
|
java.util.Enumeration |
getLocales()
|
java.lang.String |
getMethod()
|
java.lang.String |
getParameter(java.lang.String name)
|
java.util.Map |
getParameterMap()
|
java.util.Enumeration |
getParameterNames()
|
java.lang.String[] |
getParameterValues(java.lang.String name)
|
java.lang.String |
getPathInfo()
|
java.lang.String |
getPathTranslated()
|
java.lang.String |
getProtocol()
|
java.lang.String |
getQueryString()
|
java.io.BufferedReader |
getReader()
|
java.lang.String |
getRealPath(java.lang.String path)
|
java.lang.String |
getRemoteAddr()
|
java.lang.String |
getRemoteHost()
|
java.lang.String |
getRemoteUser()
|
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String path)
|
java.lang.String |
getRequestedSessionId()
|
java.lang.String |
getRequestURI()
|
java.lang.StringBuffer |
getRequestURL()
|
java.lang.String |
getScheme()
|
java.lang.String |
getServerName()
|
int |
getServerPort()
|
java.lang.String |
getServletPath()
|
javax.servlet.http.HttpSession |
getSession()
|
javax.servlet.http.HttpSession |
getSession(boolean create)
|
java.security.Principal |
getUserPrincipal()
|
boolean |
isRequestedSessionIdFromCookie()
|
boolean |
isRequestedSessionIdFromUrl()
|
boolean |
isRequestedSessionIdFromURL()
|
boolean |
isRequestedSessionIdValid()
|
boolean |
isSecure()
|
boolean |
isUserInRole(java.lang.String role)
|
void |
removeAttribute(java.lang.String name)
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
|
void |
setCharacterEncoding(java.lang.String name)
|
void |
setContentType(java.lang.String contentType)
|
void |
setHttpSession(javax.servlet.http.HttpSession session)
|
void |
setLocale(java.util.Locale locale)
|
void |
setMethod(java.lang.String method)
|
void |
setPathElements(java.lang.String contextPath,
java.lang.String servletPath,
java.lang.String pathInfo,
java.lang.String queryString)
|
void |
setUserPrincipal(java.security.Principal principal)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.HashMap attributes
The set of request attributes.
protected java.lang.String contextPath
The context path for this request.
protected java.util.Locale locale
The preferred locale for this request.
protected java.util.HashMap parameters
The set of arrays of parameter values, keyed by parameter name.
protected java.lang.String pathInfo
The extra path information for this request. v *
protected java.security.Principal principal
The authenticated user for this request.
protected java.lang.String queryString
The query string for this request.
protected java.lang.String servletPath
The servlet path for this request.
protected javax.servlet.http.HttpSession session
The HttpSession with which we are associated.
protected java.lang.String method
The HTTP request method.
protected java.lang.String contentType
The Content Type for this request.
| Constructor Detail |
|---|
public MockHttpServletRequest()
public MockHttpServletRequest(javax.servlet.http.HttpSession session)
public MockHttpServletRequest(java.lang.String contextPath,
java.lang.String servletPath,
java.lang.String pathInfo,
java.lang.String queryString)
public MockHttpServletRequest(java.lang.String contextPath,
java.lang.String servletPath,
java.lang.String pathInfo,
java.lang.String queryString,
javax.servlet.http.HttpSession session)
| Method Detail |
|---|
public void addParameter(java.lang.String name,
java.lang.String value)
public void setHttpSession(javax.servlet.http.HttpSession session)
public void setLocale(java.util.Locale locale)
public void setMethod(java.lang.String method)
public void setContentType(java.lang.String contentType)
public void setPathElements(java.lang.String contextPath,
java.lang.String servletPath,
java.lang.String pathInfo,
java.lang.String queryString)
public void setUserPrincipal(java.security.Principal principal)
public java.lang.String getAuthType()
getAuthType in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getContextPath()
getContextPath in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.Cookie[] getCookies()
getCookies in interface javax.servlet.http.HttpServletRequestpublic long getDateHeader(java.lang.String name)
getDateHeader in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getHeader(java.lang.String name)
getHeader in interface javax.servlet.http.HttpServletRequestpublic java.util.Enumeration getHeaderNames()
getHeaderNames in interface javax.servlet.http.HttpServletRequestpublic java.util.Enumeration getHeaders(java.lang.String name)
getHeaders in interface javax.servlet.http.HttpServletRequestpublic int getIntHeader(java.lang.String name)
getIntHeader in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getMethod()
getMethod in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getPathInfo()
getPathInfo in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getPathTranslated()
getPathTranslated in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getQueryString()
getQueryString in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getRemoteUser()
getRemoteUser in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getRequestedSessionId()
getRequestedSessionId in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getRequestURI()
getRequestURI in interface javax.servlet.http.HttpServletRequestpublic java.lang.StringBuffer getRequestURL()
getRequestURL in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getServletPath()
getServletPath in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.HttpSession getSession()
getSession in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.HttpSession getSession(boolean create)
getSession in interface javax.servlet.http.HttpServletRequestpublic java.security.Principal getUserPrincipal()
getUserPrincipal in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdValid()
isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequestpublic boolean isUserInRole(java.lang.String role)
isUserInRole in interface javax.servlet.http.HttpServletRequestpublic java.lang.Object getAttribute(java.lang.String name)
getAttribute in interface javax.servlet.ServletRequestpublic java.util.Enumeration getAttributeNames()
getAttributeNames in interface javax.servlet.ServletRequestpublic java.lang.String getCharacterEncoding()
getCharacterEncoding in interface javax.servlet.ServletRequestpublic int getContentLength()
getContentLength in interface javax.servlet.ServletRequestpublic java.lang.String getContentType()
getContentType in interface javax.servlet.ServletRequestpublic javax.servlet.ServletInputStream getInputStream()
getInputStream in interface javax.servlet.ServletRequestpublic java.util.Locale getLocale()
getLocale in interface javax.servlet.ServletRequestpublic java.util.Enumeration getLocales()
getLocales in interface javax.servlet.ServletRequestpublic java.lang.String getParameter(java.lang.String name)
getParameter in interface javax.servlet.ServletRequestpublic java.util.Map getParameterMap()
getParameterMap in interface javax.servlet.ServletRequestpublic java.util.Enumeration getParameterNames()
getParameterNames in interface javax.servlet.ServletRequestpublic java.lang.String[] getParameterValues(java.lang.String name)
getParameterValues in interface javax.servlet.ServletRequestpublic java.lang.String getProtocol()
getProtocol in interface javax.servlet.ServletRequestpublic java.io.BufferedReader getReader()
getReader in interface javax.servlet.ServletRequestpublic java.lang.String getRealPath(java.lang.String path)
getRealPath in interface javax.servlet.ServletRequestpublic java.lang.String getRemoteAddr()
getRemoteAddr in interface javax.servlet.ServletRequestpublic java.lang.String getRemoteHost()
getRemoteHost in interface javax.servlet.ServletRequestpublic javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
getRequestDispatcher in interface javax.servlet.ServletRequestpublic java.lang.String getScheme()
getScheme in interface javax.servlet.ServletRequestpublic java.lang.String getServerName()
getServerName in interface javax.servlet.ServletRequestpublic int getServerPort()
getServerPort in interface javax.servlet.ServletRequestpublic boolean isSecure()
isSecure in interface javax.servlet.ServletRequestpublic void removeAttribute(java.lang.String name)
removeAttribute in interface javax.servlet.ServletRequest
public void setAttribute(java.lang.String name,
java.lang.Object value)
setAttribute in interface javax.servlet.ServletRequestpublic void setCharacterEncoding(java.lang.String name)
setCharacterEncoding in interface javax.servlet.ServletRequest
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||