|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 HashMap |
attributes
The set of request attributes. |
protected String |
contentType
The Content Type for this request. |
protected String |
contextPath
The context path for this request. |
protected Locale |
locale
The preferred locale for this request. |
protected String |
method
The HTTP request method. |
protected HashMap |
parameters
The set of arrays of parameter values, keyed by parameter name. |
protected String |
pathInfo
The extra path information for this request. |
protected Principal |
principal
The authenticated user for this request. |
protected String |
queryString
The query string for this request. |
protected String |
servletPath
The servlet path for this request. |
protected 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(HttpSession session)
|
|
MockHttpServletRequest(String contextPath,
String servletPath,
String pathInfo,
String queryString)
|
|
MockHttpServletRequest(String contextPath,
String servletPath,
String pathInfo,
String queryString,
HttpSession session)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected HashMap attributes
The set of request attributes.
protected String contextPath
The context path for this request.
protected Locale locale
The preferred locale for this request.
protected HashMap parameters
The set of arrays of parameter values, keyed by parameter name.
protected String pathInfo
The extra path information for this request. v *
protected Principal principal
The authenticated user for this request.
protected String queryString
The query string for this request.
protected String servletPath
The servlet path for this request.
protected HttpSession session
The HttpSession with which we are associated.
protected String method
The HTTP request method.
protected String contentType
The Content Type for this request.
Constructor Detail |
---|
public MockHttpServletRequest()
public MockHttpServletRequest(HttpSession session)
public MockHttpServletRequest(String contextPath, String servletPath, String pathInfo, String queryString)
public MockHttpServletRequest(String contextPath, String servletPath, String pathInfo, String queryString, HttpSession session)
Method Detail |
---|
public void addParameter(String name, String value)
public void setHttpSession(HttpSession session)
public void setLocale(Locale locale)
public void setMethod(String method)
public void setContentType(String contentType)
public void setPathElements(String contextPath, String servletPath, String pathInfo, String queryString)
public void setUserPrincipal(Principal principal)
public String getAuthType()
getAuthType
in interface HttpServletRequest
public String getContextPath()
getContextPath
in interface HttpServletRequest
public Cookie[] getCookies()
getCookies
in interface HttpServletRequest
public long getDateHeader(String name)
getDateHeader
in interface HttpServletRequest
public String getHeader(String name)
getHeader
in interface HttpServletRequest
public Enumeration getHeaderNames()
getHeaderNames
in interface HttpServletRequest
public Enumeration getHeaders(String name)
getHeaders
in interface HttpServletRequest
public int getIntHeader(String name)
getIntHeader
in interface HttpServletRequest
public String getMethod()
getMethod
in interface HttpServletRequest
public String getPathInfo()
getPathInfo
in interface HttpServletRequest
public String getPathTranslated()
getPathTranslated
in interface HttpServletRequest
public String getQueryString()
getQueryString
in interface HttpServletRequest
public String getRemoteUser()
getRemoteUser
in interface HttpServletRequest
public String getRequestedSessionId()
getRequestedSessionId
in interface HttpServletRequest
public String getRequestURI()
getRequestURI
in interface HttpServletRequest
public StringBuffer getRequestURL()
getRequestURL
in interface HttpServletRequest
public String getServletPath()
getServletPath
in interface HttpServletRequest
public HttpSession getSession()
getSession
in interface HttpServletRequest
public HttpSession getSession(boolean create)
getSession
in interface HttpServletRequest
public Principal getUserPrincipal()
getUserPrincipal
in interface HttpServletRequest
public boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie
in interface HttpServletRequest
public boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl
in interface HttpServletRequest
public boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL
in interface HttpServletRequest
public boolean isRequestedSessionIdValid()
isRequestedSessionIdValid
in interface HttpServletRequest
public boolean isUserInRole(String role)
isUserInRole
in interface HttpServletRequest
public Object getAttribute(String name)
getAttribute
in interface ServletRequest
public Enumeration getAttributeNames()
getAttributeNames
in interface ServletRequest
public String getCharacterEncoding()
getCharacterEncoding
in interface ServletRequest
public int getContentLength()
getContentLength
in interface ServletRequest
public String getContentType()
getContentType
in interface ServletRequest
public ServletInputStream getInputStream()
getInputStream
in interface ServletRequest
public Locale getLocale()
getLocale
in interface ServletRequest
public Enumeration getLocales()
getLocales
in interface ServletRequest
public String getParameter(String name)
getParameter
in interface ServletRequest
public Map getParameterMap()
getParameterMap
in interface ServletRequest
public Enumeration getParameterNames()
getParameterNames
in interface ServletRequest
public String[] getParameterValues(String name)
getParameterValues
in interface ServletRequest
public String getProtocol()
getProtocol
in interface ServletRequest
public BufferedReader getReader()
getReader
in interface ServletRequest
public String getRealPath(String path)
getRealPath
in interface ServletRequest
public String getRemoteAddr()
getRemoteAddr
in interface ServletRequest
public String getRemoteHost()
getRemoteHost
in interface ServletRequest
public RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher
in interface ServletRequest
public String getScheme()
getScheme
in interface ServletRequest
public String getServerName()
getServerName
in interface ServletRequest
public int getServerPort()
getServerPort
in interface ServletRequest
public boolean isSecure()
isSecure
in interface ServletRequest
public void removeAttribute(String name)
removeAttribute
in interface ServletRequest
public void setAttribute(String name, Object value)
setAttribute
in interface ServletRequest
public void setCharacterEncoding(String name)
setCharacterEncoding
in interface ServletRequest
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |