| java.lang.Object com.uwyn.rife.test.MockRequest
MockRequest | public class MockRequest implements Request(Code) | | Provides a
Request implementation that is suitable for testing a
web application outside of a servlet container.
author: Geert Bevin (gbevin[remove] at uwyn dot com) version: $Revision: 3669 $ since: 1.1 |
Method Summary | |
public MockRequest | addDateHeader(String name, long value) Adds a request header with the given name and date-value. | public MockRequest | addHeader(String name, String value) Adds a request header with the given name and value. | public MockRequest | addIntHeader(String name, int value) Adds a request header with the given name and integer value. | public void | addLocale(Locale locale) Adds a
Locale to this request. | public MockRequest | characterEncoding(String encoding) Set the character encoding of this request. | public boolean | containsHeader(String name) Checks whether a certain request header is present. | public MockRequest | contentType(String type) Set the content type of this request. | public MockRequest | dateHeader(String name, long value) Sets a request header with the given name and date-value. | public MockRequest | file(String name, MockFileUpload file) Sets a file in this request. | public MockRequest | files(Map<String, MockFileUpload[]> files) Sets a map of files in this request. | public MockRequest | files(String name, MockFileUpload[] files) Sets files in this request. | public Object | getAttribute(String name) | public Enumeration | getAttributeNames() | public String | getCharacterEncoding() | public String | getContentType() | public String | getContextPath() | public Cookie | getCookie(String name) | public Cookie[] | getCookies() | public long | getDateHeader(String name) | public UploadedFile | getFile(String name) | public Map<String, UploadedFile[]> | getFiles() | public UploadedFile[] | getFiles(String name) | public String | getHeader(String name) | public Enumeration | getHeaderNames() | public Enumeration | getHeaders(String name) | public HttpServletRequest | getHttpServletRequest() | public int | getIntHeader(String name) | public Locale | getLocale() | public Enumeration | getLocales() | public RequestMethod | getMethod() | public Map<String, String[]> | getParameters() Retrieves all the parameters of this request. | public String | getProtocol() | public String | getRemoteAddr() | public String | getRemoteHost() | public String | getRemoteUser() | public RequestDispatcher | getRequestDispatcher(String url) | String | getRequestedSessionId() | public String | getScheme() | public String | getServerName() | public int | getServerPort() | public String | getServerRootUrl(int port) | public HttpSession | getSession(boolean create) | public HttpSession | getSession() | public boolean | hasAttribute(String name) | public boolean | hasCookie(String name) | public boolean | hasFile(String name) | public boolean | hasParameter(String name) Checks whether a named parameter is present in this request. | public MockRequest | header(String name, String value) Sets a request header with the given name and value. | public void | init(StateStore stateStore) | public MockRequest | intHeader(String name, int value) Sets a request header with the given name and integer value. | boolean | isRequestedSessionIdFromCookie() | public boolean | isSecure() | public MockRequest | locale(Locale locale) Adds a
Locale to this request. | public MockRequest | method(RequestMethod method) Sets the method of this request. | MockSession | newSession() | public MockRequest | parameter(String name, String[] values) Sets a parameter in this request. | public MockRequest | parameter(String name, String value) Sets a parameter in this request. | public MockRequest | parameters(Map<String, String[]> parameters) Sets a map of parameters in this request. | public MockRequest | protocol(String protocol) Set the protocol of this request. | public MockRequest | remoteAddr(String remoteAddr) Set the remote address of this request. | public MockRequest | remoteHost(String remoteHost) Set the remote host of this request. | public MockRequest | remoteUser(String remoteUser) Set the remote user of this request. | public void | removeAttribute(String name) | public void | removeHeader(String name) Removes a request header with the given name. | public MockRequest | secure(boolean secure) Set whether this request is secure. | public void | setAttribute(String name, Object object) | public void | setCharacterEncoding(String encoding) Set the character encoding of this request. | public void | setContentType(String type) Set the content type of this request. | public void | setDateHeader(String name, long value) Sets a request header with the given name and date-value. | public void | setFile(String name, MockFileUpload file) Sets a file in this request. | public void | setFiles(Map<String, MockFileUpload[]> files) Sets a map of files in this request. | public void | setFiles(String name, MockFileUpload[] files) Sets files in this request. | public void | setHeader(String name, String value) Sets a request header with the given name and value. | public void | setIntHeader(String name, int value) Sets a request header with the given name and integer value. | public void | setMethod(RequestMethod method) Sets the method of this request. | void | setMockConversation(MockConversation conversation) | void | setMockResponse(MockResponse response) | public void | setParameter(String name, String[] values) Sets a parameter in this request. | public void | setParameter(String name, String value) Sets a parameter in this request. | public void | setParameters(Map<String, String[]> parameters) Sets a map of parameters in this request. | public void | setProtocol(String protocol) Set the protocol of this request. | public void | setRemoteAddr(String remoteAddr) Set the remote address of this request. | public void | setRemoteHost(String remoteHost) Set the remote host of this request. | public void | setRemoteUser(String remoteUser) Set the remote user of this request. | void | setRequestedSessionId(String pathParams) | public void | setSecure(boolean secure) Set whether this request is secure. |
addDateHeader | public MockRequest addDateHeader(String name, long value)(Code) | | Adds a request header with the given name and date-value. The date is
specified in terms of milliseconds since the epoch. This method allows
request headers to have multiple values.
Parameters: name - the name of the header to set Parameters: value - the additional date value this MockRequest instance since: 1.1 |
addHeader | public MockRequest addHeader(String name, String value)(Code) | | Adds a request header with the given name and value. This method allows
request headers to have multiple values.
Parameters: name - the name of the header to set Parameters: value - the additional header value this MockRequest instance since: 1.1 |
addIntHeader | public MockRequest addIntHeader(String name, int value)(Code) | | Adds a request header with the given name and integer value. This
method allows request headers to have multiple values.
Parameters: name - the name of the header to set Parameters: value - the additional integer value this MockRequest instance since: 1.1 |
addLocale | public void addLocale(Locale locale)(Code) | | Adds a
Locale to this request.
Parameters: locale - the locale to add since: 1.1 |
characterEncoding | public MockRequest characterEncoding(String encoding)(Code) | | Set the character encoding of this request.
Parameters: encoding - the name of the character encoding this MockRequest instance since: 1.1 |
containsHeader | public boolean containsHeader(String name)(Code) | | Checks whether a certain request header is present.
Parameters: name - the name of the header to check true if the header was present; orfalse otherwise since: 1.1
|
contentType | public MockRequest contentType(String type)(Code) | | Set the content type of this request.
Parameters: type - the content type this MockRequest instance since: 1.1 |
dateHeader | public MockRequest dateHeader(String name, long value)(Code) | | Sets a request header with the given name and date-value.
Parameters: name - the name of the header to set Parameters: value - the assigned date value See Also: MockRequest.setDateHeader since: 1.1 |
getCharacterEncoding | public String getCharacterEncoding()(Code) | | |
getServerPort | public int getServerPort()(Code) | | |
getServerRootUrl | public String getServerRootUrl(int port)(Code) | | |
intHeader | public MockRequest intHeader(String name, int value)(Code) | | Sets a request header with the given name and integer value.
Parameters: name - the name of the header to set Parameters: value - the assigned integer value See Also: MockRequest.setDateHeader since: 1.1 |
isRequestedSessionIdFromCookie | boolean isRequestedSessionIdFromCookie()(Code) | | |
isSecure | public boolean isSecure()(Code) | | |
locale | public MockRequest locale(Locale locale)(Code) | | Adds a
Locale to this request.
Parameters: locale - the locale to add this MockRequest instance since: 1.1 |
protocol | public MockRequest protocol(String protocol)(Code) | | Set the protocol of this request.
Parameters: protocol - the protocol to set this MockRequest instance since: 1.1 |
remoteAddr | public MockRequest remoteAddr(String remoteAddr)(Code) | | Set the remote address of this request.
Parameters: remoteAddr - the remote address to set this MockRequest instance since: 1.1 |
remoteHost | public MockRequest remoteHost(String remoteHost)(Code) | | Set the remote host of this request.
Parameters: remoteHost - the remote host to set this MockRequest instance since: 1.1 |
remoteUser | public MockRequest remoteUser(String remoteUser)(Code) | | Set the remote user of this request.
Parameters: remoteUser - the remote user to set this MockRequest instance since: 1.1 |
removeAttribute | public void removeAttribute(String name)(Code) | | |
removeHeader | public void removeHeader(String name)(Code) | | Removes a request header with the given name.
Parameters: name - the name of the header to remove since: 1.1 |
secure | public MockRequest secure(boolean secure)(Code) | | Set whether this request is secure.
Parameters: secure - true if this request is secure; orfalse otherwise this MockRequest instance since: 1.1
|
setCharacterEncoding | public void setCharacterEncoding(String encoding)(Code) | | Set the character encoding of this request.
Parameters: encoding - the name of the character encoding since: 1.1 |
setContentType | public void setContentType(String type)(Code) | | Set the content type of this request.
Parameters: type - the content type since: 1.1 |
setDateHeader | public void setDateHeader(String name, long value)(Code) | | Sets a request header with the given name and date-value. The date is
specified in terms of milliseconds since the epoch. If the header had
already been set, the new value overwrites the previous one. The
MockRequest.containsHeader method can be used to test for the presence of a
header before setting its value.
Parameters: name - the name of the header to set Parameters: value - the assigned date value since: 1.1 |
setHeader | public void setHeader(String name, String value)(Code) | | Sets a request header with the given name and value. If the header had
already been set, the new value overwrites the previous one. The
MockRequest.containsHeader method can be used to test for the presence of a
header before setting its value.
Parameters: name - the name of the header to set Parameters: value - the header value since: 1.1 |
setIntHeader | public void setIntHeader(String name, int value)(Code) | | Sets a request header with the given name and integer value. If the
header had already been set, the new value overwrites the previous one.
The containsHeader method can be used to test for the presence of a
header before setting its value.
Parameters: name - the name of the header to set Parameters: value - the assigned integer value since: 1.1 |
setProtocol | public void setProtocol(String protocol)(Code) | | Set the protocol of this request.
The default protocol is "HTTP/1.1" .
Parameters: protocol - the protocol to set since: 1.1 |
setRemoteAddr | public void setRemoteAddr(String remoteAddr)(Code) | | Set the remote address of this request.
The default remote address is "127.0.0.1" .
Parameters: remoteAddr - the remote address to set since: 1.1 |
setRemoteHost | public void setRemoteHost(String remoteHost)(Code) | | Set the remote host of this request.
The default remote host is "localhost ".
Parameters: remoteHost - the remote host to set since: 1.1 |
setRemoteUser | public void setRemoteUser(String remoteUser)(Code) | | Set the remote user of this request.
The default remote user is null .
Parameters: remoteUser - the remote user to set since: 1.1 |
setRequestedSessionId | void setRequestedSessionId(String pathParams)(Code) | | |
setSecure | public void setSecure(boolean secure)(Code) | | Set whether this request is secure.
A request is not secure by default.
Parameters: secure - true if this request is secure; or false otherwise since: 1.1
|
|
|