|
||||||||||
| 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 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 HttpServletRequestpublic String getContextPath()
getContextPath in interface HttpServletRequestpublic Cookie[] getCookies()
getCookies in interface HttpServletRequestpublic long getDateHeader(String name)
getDateHeader in interface HttpServletRequestpublic String getHeader(String name)
getHeader in interface HttpServletRequestpublic Enumeration getHeaderNames()
getHeaderNames in interface HttpServletRequestpublic Enumeration getHeaders(String name)
getHeaders in interface HttpServletRequestpublic int getIntHeader(String name)
getIntHeader in interface HttpServletRequestpublic String getMethod()
getMethod in interface HttpServletRequestpublic String getPathInfo()
getPathInfo in interface HttpServletRequestpublic String getPathTranslated()
getPathTranslated in interface HttpServletRequestpublic String getQueryString()
getQueryString in interface HttpServletRequestpublic String getRemoteUser()
getRemoteUser in interface HttpServletRequestpublic String getRequestedSessionId()
getRequestedSessionId in interface HttpServletRequestpublic String getRequestURI()
getRequestURI in interface HttpServletRequestpublic StringBuffer getRequestURL()
getRequestURL in interface HttpServletRequestpublic String getServletPath()
getServletPath in interface HttpServletRequestpublic HttpSession getSession()
getSession in interface HttpServletRequestpublic HttpSession getSession(boolean create)
getSession in interface HttpServletRequestpublic Principal getUserPrincipal()
getUserPrincipal in interface HttpServletRequestpublic boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie in interface HttpServletRequestpublic boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl in interface HttpServletRequestpublic boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL in interface HttpServletRequestpublic boolean isRequestedSessionIdValid()
isRequestedSessionIdValid in interface HttpServletRequestpublic boolean isUserInRole(String role)
isUserInRole in interface HttpServletRequestpublic Object getAttribute(String name)
getAttribute in interface ServletRequestpublic Enumeration getAttributeNames()
getAttributeNames in interface ServletRequestpublic String getCharacterEncoding()
getCharacterEncoding in interface ServletRequestpublic int getContentLength()
getContentLength in interface ServletRequestpublic String getContentType()
getContentType in interface ServletRequestpublic ServletInputStream getInputStream()
getInputStream in interface ServletRequestpublic Locale getLocale()
getLocale in interface ServletRequestpublic Enumeration getLocales()
getLocales in interface ServletRequestpublic String getParameter(String name)
getParameter in interface ServletRequestpublic Map getParameterMap()
getParameterMap in interface ServletRequestpublic Enumeration getParameterNames()
getParameterNames in interface ServletRequestpublic String[] getParameterValues(String name)
getParameterValues in interface ServletRequestpublic String getProtocol()
getProtocol in interface ServletRequestpublic BufferedReader getReader()
getReader in interface ServletRequestpublic String getRealPath(String path)
getRealPath in interface ServletRequestpublic String getRemoteAddr()
getRemoteAddr in interface ServletRequestpublic String getRemoteHost()
getRemoteHost in interface ServletRequestpublic RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher in interface ServletRequestpublic String getScheme()
getScheme in interface ServletRequestpublic String getServerName()
getServerName in interface ServletRequestpublic int getServerPort()
getServerPort in interface ServletRequestpublic boolean isSecure()
isSecure in interface ServletRequestpublic void removeAttribute(String name)
removeAttribute in interface ServletRequest
public void setAttribute(String name,
Object value)
setAttribute in interface ServletRequestpublic void setCharacterEncoding(String name)
setCharacterEncoding in interface ServletRequest
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||