Class TestableRequestImpl
java.lang.Object
org.apache.tapestry5.internal.test.TestableRequestImpl
- All Implemented Interfaces:
Request
,TestableRequest
-
Field Summary
Fields inherited from interface org.apache.tapestry5.http.services.Request
REQUESTED_WITH_HEADER, X_FORWARDED_PROTO_HEADER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclear()
Clears the internal parameters map.getAttribute
(String name) Returns the value of the named attribute as anObject
, ornull
if no attribute of the given name exists.Returns a sorted list of attribute names.Returns the context path.long
getDateHeader
(String name) Returns the value of the specified request header as along
value that represents aDate
object.Returns null.Returns an empty list.Returns the locale of the client as determined from the request headers.int
Always returns 80.Always returns POST, to keep the Form component happy.getParameter
(String name) Returns the query parameter value for the given name.Returns a list of query parameter names, in alphabetical order.String[]
getParameters
(String name) Returns the parameter values for the given name.getPath()
Returns the path portion of the request, which starts with a "/" and contains everything up to the start of the query parameters.Always returns "localhost".Returns "localhost" which is sufficient for testing purposes.int
Always returns 80.getSession
(boolean create) Gets theSession
.boolean
Always returns true.boolean
isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.boolean
Returns true if the request specified a session, and that session has been invalidated.boolean
isXHR()
Always returns false.loadParameter
(String parameterName, String parameterValue) Loads a single parameter/value pair.overrideParameter
(String parameterName, String parameterValue) Overrides a parameter to the specific value, regardless of how the parameter was previously set.void
setAttribute
(String name, Object value) Stores an attribute in this request.void
setEncoding
(String requestEncoding) Sets the locale requested by "the browser".Sets the path; the path should begin with a "/" character and contain everything from there to the start of query parameters (if any).
-
Constructor Details
-
TestableRequestImpl
-
-
Method Details
-
clear
Description copied from interface:TestableRequest
Clears the internal parameters map.- Specified by:
clear
in interfaceTestableRequest
- Returns:
- the request for further configuration
-
setPath
Description copied from interface:TestableRequest
Sets the path; the path should begin with a "/" character and contain everything from there to the start of query parameters (if any).- Specified by:
setPath
in interfaceTestableRequest
- Returns:
- the request for further configuration
-
setLocale
Description copied from interface:TestableRequest
Sets the locale requested by "the browser".- Specified by:
setLocale
in interfaceTestableRequest
- Returns:
- the request for further configuration
-
loadParameter
Description copied from interface:TestableRequest
Loads a single parameter/value pair. This may define a new parameter, or add a value to a list of parameters.- Specified by:
loadParameter
in interfaceTestableRequest
- Returns:
- the request for further configuration
-
overrideParameter
Description copied from interface:TestableRequest
Overrides a parameter to the specific value, regardless of how the parameter was previously set.- Specified by:
overrideParameter
in interfaceTestableRequest
-
getDateHeader
Description copied from interface:Request
Returns the value of the specified request header as along
value that represents aDate
object. Use this method with headers that contain dates, such asIf-Modified-Since
. The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive. If the request did not have a header of the specified name, this method returns -1. If the header can't be converted to a date, the method throws anIllegalArgumentException
.- Specified by:
getDateHeader
in interfaceRequest
- Parameters:
name
- aString
specifying the name of the header- Returns:
- a
long
value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the reqest
-
getHeader
Returns null. -
getHeaderNames
Returns an empty list.- Specified by:
getHeaderNames
in interfaceRequest
-
getLocale
Description copied from interface:Request
Returns the locale of the client as determined from the request headers. -
getParameterNames
Description copied from interface:Request
Returns a list of query parameter names, in alphabetical order.- Specified by:
getParameterNames
in interfaceRequest
-
getParameters
Description copied from interface:Request
Returns the parameter values for the given name. Returns null if no such parameter is in the request.- Specified by:
getParameters
in interfaceRequest
-
getPath
Description copied from interface:Request
Returns the path portion of the request, which starts with a "/" and contains everything up to the start of the query parameters. It doesn't include the context path. -
getContextPath
Description copied from interface:Request
Returns the context path. This always starts with a "/" character and does not end with one, with the exception of servlets in the root context, which return the empty string.- Specified by:
getContextPath
in interfaceRequest
-
getParameter
Description copied from interface:Request
Returns the query parameter value for the given name. Returns null if no such parameter is in the request. For a multi-valued parameter, returns just the first value.- Specified by:
getParameter
in interfaceRequest
-
getSession
Description copied from interface:Request
Gets theSession
. If create is false and the session has not be created previously, returns null. Also, if the session is invalidated and create is false, returns null. Invoking this method with true, when the session exists but has been invalidated, will force the creation of a new session.- Specified by:
getSession
in interfaceRequest
- Parameters:
create
- true to force the creation of the session- Returns:
- the session (or null if create is false the session has not been previously created)
-
setEncoding
-
isXHR
Always returns false. If you need to test Ajax functionality, you need to be using Selenium. -
isSecure
Description copied from interface:Request
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS. -
isRequestedSessionIdValid
Always returns true.- Specified by:
isRequestedSessionIdValid
in interfaceRequest
- Returns:
- true if the request included a session id that is still active, false if the included session id has expired
-
getAttribute
Description copied from interface:Request
Returns the value of the named attribute as anObject
, ornull
if no attribute of the given name exists. Because this method is a wrapper aroundServletRequest.getAttribute(String)
, it is case sensitive (unlike most of Tapestry).- Specified by:
getAttribute
in interfaceRequest
- Parameters:
name
- aString
specifying the name of the attribute- Returns:
- an
Object
containing the value of the attribute, ornull
if the attribute does not exist
-
getAttributeNames
Description copied from interface:Request
Returns a sorted list of attribute names.- Specified by:
getAttributeNames
in interfaceRequest
-
setAttribute
Description copied from interface:Request
Stores an attribute in this request. Attributes are reset between requests (and remember that in Tapestry, there is usually two requests per operation: the action request that redirects to a render request).- Specified by:
setAttribute
in interfaceRequest
- Parameters:
name
- aString
specifying the name of the attributevalue
- theObject
to be stored, or null to remove the attribute
-
getServerName
Returns "localhost" which is sufficient for testing purposes.- Specified by:
getServerName
in interfaceRequest
- Returns:
- the name of the server
-
getMethod
Always returns POST, to keep the Form component happy. -
getLocalPort
Always returns 80.- Specified by:
getLocalPort
in interfaceRequest
- Returns:
- an integer specifying the port number
-
getServerPort
Always returns 80.- Specified by:
getServerPort
in interfaceRequest
- Returns:
- an integer specifying the port number
- Since:
- 5.2.5
-
getRemoteHost
Always returns "localhost".- Specified by:
getRemoteHost
in interfaceRequest
- Returns:
- a
String
containing the fully qualified name of the client - Since:
- 5.3
-
isSessionInvalidated
Description copied from interface:Request
Returns true if the request specified a session, and that session has been invalidated.- Specified by:
isSessionInvalidated
in interfaceRequest
- Returns:
- true if session was invalidated during this request
-