java.lang.Object | |
↳ | org.springframework.mock.web.MockHttpServletRequest |
Known Direct Subclasses |
Mock implementation of the javax.servlet.http.HttpServletRequest interface. Supports the Servlet 2.5 API level.
Used for testing the web framework; also useful for testing application controllers.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | DEFAULT_PROTOCOL | The default protocol: 'http'. | |||||||||
String | DEFAULT_REMOTE_ADDR | The default remote address: '127.0.0.1'. | |||||||||
String | DEFAULT_REMOTE_HOST | The default remote host: 'localhost'. | |||||||||
String | DEFAULT_SERVER_ADDR | The default server address: '127.0.0.1'. | |||||||||
String | DEFAULT_SERVER_NAME | The default server name: 'localhost'. | |||||||||
int | DEFAULT_SERVER_PORT | The default server port: '80'. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
javax.servlet.http.HttpServletRequest
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new MockHttpServletRequest with a default
MockServletContext . | |||||||||||
Create a new MockHttpServletRequest with a default
MockServletContext . | |||||||||||
Create a new MockHttpServletRequest.
| |||||||||||
Create a new MockHttpServletRequest.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a header entry for the given name.
| |||||||||||
Add a single value for the specified HTTP parameter.
| |||||||||||
Add an array of values for the specified HTTP parameter.
| |||||||||||
Adds all provided parameters
| |||||||||||
Add a new preferred locale, before any existing locales.
| |||||||||||
Clear all of this request's attributes.
| |||||||||||
Mark this request as completed, keeping its state.
| |||||||||||
Return the ServletContext that this request is associated with.
| |||||||||||
Invalidate this request, clearing its state.
| |||||||||||
Return whether this request is still active (that is, not completed yet).
| |||||||||||
Removes all existing parameters.
| |||||||||||
Remove already registered values for the specified HTTP parameter, if
any.
| |||||||||||
Set an array of values for the specified HTTP parameter.
| |||||||||||
Set a single value for the specified HTTP parameter.
| |||||||||||
Sets all provided parameters
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Check whether this request is still active (that is, not completed yet),
throwing an IllegalStateException if not active anymore.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
javax.servlet.ServletRequest
| |||||||||||
From interface
javax.servlet.http.HttpServletRequest
|
The default remote address: '127.0.0.1'.
The default remote host: 'localhost'.
The default server address: '127.0.0.1'.
The default server name: 'localhost'.
The default server port: '80'.
Create a new MockHttpServletRequest with a default
MockServletContext
.
Create a new MockHttpServletRequest with a default
MockServletContext
.
method | the request method (may be null ) |
---|---|
requestURI | the request URI (may be null ) |
Create a new MockHttpServletRequest.
servletContext | the ServletContext that the request runs in (may be
null to use a default MockServletContext) |
---|
Create a new MockHttpServletRequest.
servletContext | the ServletContext that the request runs in (may be
null to use a default MockServletContext) |
---|---|
method | the request method (may be null ) |
requestURI | the request URI (may be null ) |
Add a header entry for the given name.
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.
Add a single value for the specified HTTP parameter.
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.
Add an array of values for the specified HTTP parameter.
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.
Adds all provided parameters setParameters(java.util.Map)
.
Add a new preferred locale, before any existing locales.
Clear all of this request's attributes.
Mark this request as completed, keeping its state.
Return the ServletContext that this request is associated with. (Not available in the standard HttpServletRequest interface for some reason.)
Invalidate this request, clearing its state.
Return whether this request is still active (that is, not completed yet).
Removes all existing parameters.
Remove already registered values for the specified HTTP parameter, if any.
Set an array of values for the specified HTTP parameter.
If there are already one or more values registered for the given parameter name, they will be replaced.
Set a single value for the specified HTTP parameter.
If there are already one or more values registered for the given parameter name, they will be replaced.
Sets all provided parameters addParameters(java.util.Map)
.
Check whether this request is still active (that is, not completed yet), throwing an IllegalStateException if not active anymore.
IllegalStateException |
---|