|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.mock.web.MockHttpServletRequest
Mock implementation of the HttpServletRequest interface.
Used for testing the web framework; also useful for testing application controllers.
Field Summary | |
static String |
DEFAULT_PROTOCOL
|
static String |
DEFAULT_REMOTE_ADDR
|
static String |
DEFAULT_REMOTE_HOST
|
static String |
DEFAULT_SERVER_ADDR
|
static String |
DEFAULT_SERVER_NAME
|
static int |
DEFAULT_SERVER_PORT
|
Fields inherited from interface javax.servlet.http.HttpServletRequest |
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH |
Constructor Summary | |
MockHttpServletRequest()
Create a new MockHttpServletRequest with a MockServletContext. |
|
MockHttpServletRequest(ServletContext servletContext)
Create a new MockHttpServletRequest. |
|
MockHttpServletRequest(ServletContext servletContext,
String method,
String requestURI)
Create a new MockHttpServletRequest. |
|
MockHttpServletRequest(String method,
String requestURI)
Create a new MockHttpServletRequest with a MockServletContext. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String DEFAULT_PROTOCOL
public static final String DEFAULT_SERVER_ADDR
public static final String DEFAULT_SERVER_NAME
public static final int DEFAULT_SERVER_PORT
public static final String DEFAULT_REMOTE_ADDR
public static final String DEFAULT_REMOTE_HOST
Constructor Detail |
public MockHttpServletRequest(ServletContext servletContext)
servletContext
- the ServletContext that the request runs inpublic MockHttpServletRequest(ServletContext servletContext, String method, String requestURI)
servletContext
- the ServletContext that the request runs inmethod
- the request methodrequestURI
- the request URIsetMethod(java.lang.String)
,
setRequestURI(java.lang.String)
public MockHttpServletRequest()
MockServletContext
public MockHttpServletRequest(String method, String requestURI)
method
- the request methodrequestURI
- the request URIsetMethod(java.lang.String)
,
setRequestURI(java.lang.String)
,
MockServletContext
Method Detail |
public Object getAttribute(String name)
getAttribute
in interface ServletRequest
public Enumeration getAttributeNames()
getAttributeNames
in interface ServletRequest
public String getCharacterEncoding()
getCharacterEncoding
in interface ServletRequest
public void setCharacterEncoding(String characterEncoding)
setCharacterEncoding
in interface ServletRequest
public void setContent(byte[] content)
public int getContentLength()
getContentLength
in interface ServletRequest
public void setContentType(String contentType)
public String getContentType()
getContentType
in interface ServletRequest
public ServletInputStream getInputStream()
getInputStream
in interface ServletRequest
public void addParameter(String name, String value)
If there are already one or more values registered for the given parameter name, the given value will be added to the end of the list.
public void addParameter(String name, String[] values)
If there are already one or more values registered for the given parameter name, the given values will be added to the end of the list.
public String getParameter(String name)
getParameter
in interface ServletRequest
public Enumeration getParameterNames()
getParameterNames
in interface ServletRequest
public String[] getParameterValues(String name)
getParameterValues
in interface ServletRequest
public Map getParameterMap()
getParameterMap
in interface ServletRequest
public void setProtocol(String protocol)
public String getProtocol()
getProtocol
in interface ServletRequest
public void setScheme(String scheme)
public String getScheme()
getScheme
in interface ServletRequest
public void setServerName(String serverName)
public String getServerName()
getServerName
in interface ServletRequest
public void setServerPort(int serverPort)
public int getServerPort()
getServerPort
in interface ServletRequest
public BufferedReader getReader() throws UnsupportedEncodingException
getReader
in interface ServletRequest
UnsupportedEncodingException
public void setRemoteAddr(String remoteAddr)
public String getRemoteAddr()
getRemoteAddr
in interface ServletRequest
public void setRemoteHost(String remoteHost)
public String getRemoteHost()
getRemoteHost
in interface ServletRequest
public void setAttribute(String name, Object value)
setAttribute
in interface ServletRequest
public void removeAttribute(String name)
removeAttribute
in interface ServletRequest
public void addPreferredLocale(Locale locale)
public Locale getLocale()
getLocale
in interface ServletRequest
public Enumeration getLocales()
getLocales
in interface ServletRequest
public void setSecure(boolean secure)
public boolean isSecure()
isSecure
in interface ServletRequest
public RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher
in interface ServletRequest
public String getRealPath(String path)
getRealPath
in interface ServletRequest
public void setRemotePort(int remotePort)
public int getRemotePort()
getRemotePort
in interface ServletRequest
public void setLocalName(String localName)
public String getLocalName()
getLocalName
in interface ServletRequest
public void setLocalAddr(String localAddr)
public String getLocalAddr()
getLocalAddr
in interface ServletRequest
public void setLocalPort(int localPort)
public int getLocalPort()
getLocalPort
in interface ServletRequest
public void setAuthType(String authType)
public String getAuthType()
getAuthType
in interface HttpServletRequest
public void setCookies(Cookie[] cookies)
public Cookie[] getCookies()
getCookies
in interface HttpServletRequest
public void addHeader(String name, Object value)
If there was no entry for that header name before, the value will be used as-is. In case of an existing entry, a String array will be created, adding the given value (more specifically, its toString representation) as further element.
Multiple values can only be stored as list of Strings,
following the Servlet spec (see getHeaders
accessor).
As alternative to repeated addHeader
calls for
individual elements, you can use a single call with an entire
array or Collection of values as parameter.
getHeaderNames()
,
getHeader(java.lang.String)
,
getHeaders(java.lang.String)
,
getDateHeader(java.lang.String)
,
getIntHeader(java.lang.String)
public long getDateHeader(String name)
getDateHeader
in interface HttpServletRequest
public String getHeader(String name)
getHeader
in interface HttpServletRequest
public Enumeration getHeaders(String name)
getHeaders
in interface HttpServletRequest
public Enumeration getHeaderNames()
getHeaderNames
in interface HttpServletRequest
public int getIntHeader(String name)
getIntHeader
in interface HttpServletRequest
public void setMethod(String method)
public String getMethod()
getMethod
in interface HttpServletRequest
public void setPathInfo(String pathInfo)
public String getPathInfo()
getPathInfo
in interface HttpServletRequest
public String getPathTranslated()
getPathTranslated
in interface HttpServletRequest
public void setContextPath(String contextPath)
public String getContextPath()
getContextPath
in interface HttpServletRequest
public void setQueryString(String queryString)
public String getQueryString()
getQueryString
in interface HttpServletRequest
public void setRemoteUser(String remoteUser)
public String getRemoteUser()
getRemoteUser
in interface HttpServletRequest
public void addRole(String role)
addUserRole(java.lang.String)
public void addUserRole(String role)
public boolean isUserInRole(String role)
isUserInRole
in interface HttpServletRequest
public void setUserPrincipal(Principal userPrincipal)
public Principal getUserPrincipal()
getUserPrincipal
in interface HttpServletRequest
public String getRequestedSessionId()
getRequestedSessionId
in interface HttpServletRequest
public void setRequestURI(String requestURI)
public String getRequestURI()
getRequestURI
in interface HttpServletRequest
public StringBuffer getRequestURL()
getRequestURL
in interface HttpServletRequest
public void setServletPath(String servletPath)
public String getServletPath()
getServletPath
in interface HttpServletRequest
public void setSession(HttpSession session)
public HttpSession getSession(boolean create)
getSession
in interface HttpServletRequest
public HttpSession getSession()
getSession
in interface HttpServletRequest
public void setRequestedSessionIdValid(boolean requestedSessionIdValid)
public boolean isRequestedSessionIdValid()
isRequestedSessionIdValid
in interface HttpServletRequest
public void setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie)
public boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie
in interface HttpServletRequest
public void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)
public boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL
in interface HttpServletRequest
public boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl
in interface HttpServletRequest
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |