org.apache.cactus
Class WebRequest
java.lang.Object
org.apache.cactus.BaseWebRequest
org.apache.cactus.WebRequest
- All Implemented Interfaces:
- Request
- public class WebRequest
- extends BaseWebRequest
Extends BaseWebRequest
to add properties specific to the
Cactus Web Redirectors.
- Version:
- $Id: WebRequest.java,v 1.25 2003/06/26 22:14:00 cmlenz Exp $
- Author:
- Vincent Massol, Jason Robertson
Methods inherited from class org.apache.cactus.BaseWebRequest |
addCookie, addCookie, addCookie, addHeader, addParameter, addParameter, getAuthentication, getConfiguration, getContentType, getCookies, getHeader, getHeaderNames, getHeaderValues, getParameterGet, getParameterNamesGet, getParameterNamesPost, getParameterPost, getParameterValuesGet, getParameterValuesPost, getUserData, setAuthentication, setConfiguration, setContentType, setUserData |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
WebRequest
public WebRequest()
- Default constructor that requires that
BaseWebRequest.setConfiguration(Configuration)
be called before the methods
requiring a configuration object.
WebRequest
public WebRequest(WebConfiguration theConfiguration)
- Parameters:
theConfiguration
- the Cactus configuration
setRedirectorName
public void setRedirectorName(java.lang.String theRedirectorName)
- Override the redirector Name defined in
cactus.properties
.
This is useful to define a per test case Name (for example, if some
test case need to have authentication turned on and not other tests,
etc).
- Parameters:
theRedirectorName
- the new redirector Name to use
getRedirectorName
public java.lang.String getRedirectorName()
- Returns:
- the overriden redirector Name or null if none has been defined
setAutomaticSession
public void setAutomaticSession(boolean isAutomaticSession)
- Parameters:
isAutomaticSession
- whether the redirector servlet will
automatically create the HTTP session or not. Default is true.
getAutomaticSession
public boolean getAutomaticSession()
- Returns:
- true if session will be automatically created for the user or
false otherwise.
setURL
public 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. A URL is of the form :
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.
- Parameters:
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.
getURL
public ServletURL getURL()
- Returns:
- the simulated URL
toString
public java.lang.String toString()
- Overrides:
toString
in class BaseWebRequest
- Returns:
- a string representation of the request
getSessionCookie
public HttpSessionCookie getSessionCookie()
- Gets an HTTP session id by calling the server side and retrieving
the jsessionid cookie in the HTTP response. This is achieved by
calling the Cactus redirector used by the current test case.
- Returns:
- the HTTP session id as a
HttpSessionCookie
object
Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.