|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.cactus.WebRequest
Contains all HTTP request data for a test case. It is the data that
will be sent to the server redirector and that will be available to the test
methods through the HttpServletRequest
object.
Namely, it is :
HttpServletRequest.getParameters()
,HttpServletRequest.getCookies()
,HttpServletRequest.getHeader(), getHeaders(),
...
APIs,HttpServletRequest.getRequestURI(), ...
Field Summary | |
static java.lang.String |
GET_METHOD
GET Method identifier. |
static java.lang.String |
POST_METHOD
POST Method identifier. |
Constructor Summary | |
WebRequest()
|
Method Summary | |
void |
addCookie(Cookie theCookie)
Adds a cookie to the request. |
void |
addCookie(java.lang.String theName,
java.lang.String theValue)
Adds a cookie to the request. |
void |
addCookie(java.lang.String theDomain,
java.lang.String theName,
java.lang.String theValue)
Adds a cookie to the request. |
void |
addHeader(java.lang.String theName,
java.lang.String theValue)
Adds a header to the request. |
void |
addParameter(java.lang.String theName,
java.lang.String theValue)
Adds a parameter to the request. |
boolean |
getAutomaticSession()
|
java.util.Vector |
getCookies()
|
java.lang.String |
getHeader(java.lang.String theName)
Returns the first value corresponding to this header's name. |
java.util.Enumeration |
getHeaderNames()
|
java.lang.String[] |
getHeaderValues(java.lang.String theName)
Returns all the values associated with this header's name. |
java.lang.String |
getMethod()
|
java.lang.String |
getParameter(java.lang.String theName)
Returns the first value corresponding to this parameter's name. |
java.util.Enumeration |
getParameterNames()
|
java.lang.String[] |
getParameterValues(java.lang.String theName)
Returns all the values associated with this parameter's name. |
ServletURL |
getURL()
|
void |
setAutomaticSession(boolean isAutomaticSession)
|
void |
setMethod(java.lang.String theMethod)
|
void |
setURL(java.lang.String theServerName,
java.lang.String theContextPath,
java.lang.String theServletPath,
java.lang.String thePathInfo,
java.lang.String theQueryString)
Sets the simulated URL. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String GET_METHOD
public static final java.lang.String POST_METHOD
Constructor Detail |
public WebRequest()
Method Detail |
public void setMethod(java.lang.String theMethod)
theMethod
- the method to use to post data (GET or POST)public java.lang.String getMethod()
public void setAutomaticSession(boolean isAutomaticSession)
isAutomaticSession
- whether the redirector servlet will
automatically create the HTTP session or not. Default is true.public boolean getAutomaticSession()
public void setURL(java.lang.String theServerName, java.lang.String theContextPath, java.lang.String theServletPath, java.lang.String thePathInfo, java.lang.String theQueryString)
URL = "http://" + serverName (including port) + requestURI ? queryString
requestURI = contextPath + servletPath + pathInfo
From the Servlet 2.2 specification :
- Context Path: The path prefix associated with the
ServletContext that this servlet is a part of. If this context is the
default context rooted at the base of the web server's URL namespace,
this path will be an empty string. Otherwise, this path starts with a
character but does not end with a character.
- Servlet Path: The path section that directly corresponds to
the mapping which activated this request. This path starts with a
character.
- PathInfo: The part of the request path that is not part of the
Context Path or the Servlet Path.
theServerName
- the server name (and port) in the URL to simulate,
i.e. this is the name that will be returned by the
HttpServletRequest.getServerName()
and
HttpServletRequest.getServerPort()
.theContextPath
- the webapp context path in the URL to simulate,
i.e. this is the name that will be returned by the
HttpServletRequest.getContextPath()
.
Can be null. Format: "/" + name or an empty string
for the default context.theServletPath
- the servlet path in the URL to simulate,
i.e. this is the name that will be returned by the
HttpServletRequest.getServletPath()
.
Can be null. Format : "/" + name.thePathInfo
- the path info in the URL to simulate, i.e. this is
the name that will be returned by the
HttpServletRequest.getPathInfo()
. Can
be null. Format : "/" + name.theQueryString
- the Query string in the URL to simulate, i.e. this
is the string that will be returned by the
HttpServletResquest.getQueryString()
.
Can be null.public ServletURL getURL()
public void addParameter(java.lang.String theName, java.lang.String theValue)
HttpServletRequest
).theName
- the parameter's nametheValue
- the parameter's valuepublic java.util.Enumeration getParameterNames()
public java.lang.String getParameter(java.lang.String theName)
theName
- the parameter's namepublic java.lang.String[] getParameterValues(java.lang.String theName)
theName
- the parameter's namepublic void addCookie(java.lang.String theName, java.lang.String theValue)
addCookie(String theDomain, String theName,
String theValue)
method or the
addCookie(Cookie theCookie)
if you wish to specify a
domain.
Note that the domain must match either the redirector host
(specified in cactus.properties
) or the host set
using setURL()
.theName
- the cookie's nametheValue
- the cookie's valuepublic void addCookie(java.lang.String theDomain, java.lang.String theName, java.lang.String theValue)
cactus.properties
) or the host set
using setURL()
.theDomain
- the cookie domaintheName
- the cookie nametheValue
- the cookie valuepublic void addCookie(Cookie theCookie)
cactus.properties
) or the host set
using setURL()
.theCookie
- the cookie to addpublic java.util.Vector getCookies()
Cookie
objects)public void addHeader(java.lang.String theName, java.lang.String theValue)
theName
- the header's nametheValue
- the header's valuepublic java.util.Enumeration getHeaderNames()
public java.lang.String getHeader(java.lang.String theName)
theName
- the header's namepublic java.lang.String[] getHeaderValues(java.lang.String theName)
theName
- the header's namepublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |