org.apache.cactus.internal
Class WebRequestImpl

java.lang.Object
  extended by org.apache.cactus.internal.BaseWebRequest
      extended by org.apache.cactus.internal.WebRequestImpl
All Implemented Interfaces:
Request, WebRequest

public class WebRequestImpl
extends BaseWebRequest

Extends BaseWebRequest to add properties specific to the Cactus Web Redirectors.

Version:
$Id: WebRequestImpl.java 238991 2004-05-22 11:34:50Z vmassol $

Field Summary
 
Fields inherited from interface org.apache.cactus.WebRequest
GET_METHOD, POST_METHOD
 
Constructor Summary
WebRequestImpl()
          Default constructor that requires that BaseWebRequest.setConfiguration(Configuration) be called before the methods requiring a configuration object.
WebRequestImpl(WebConfiguration theConfiguration)
           
 
Method Summary
 boolean getAutomaticSession()
          
 java.lang.String getRedirectorName()
          
 HttpSessionCookie getSessionCookie()
          Gets an HTTP session id by calling the server side and retrieving the jsessionid cookie in the HTTP response.
 ServletURL getURL()
          
 void setAutomaticSession(boolean isAutomaticSession)
          
 void setRedirectorName(java.lang.String theRedirectorName)
          Override the redirector Name defined in cactus.properties.
 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 org.apache.cactus.internal.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
 

Constructor Detail

WebRequestImpl

public WebRequestImpl()
Default constructor that requires that BaseWebRequest.setConfiguration(Configuration) be called before the methods requiring a configuration object.


WebRequestImpl

public WebRequestImpl(WebConfiguration theConfiguration)
Parameters:
theConfiguration - the Cactus configuration
Method Detail

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
See Also:
WebRequest.setRedirectorName(String)

getRedirectorName

public java.lang.String getRedirectorName()

Returns:
the overriden redirector Name or null if none has been defined
See Also:
WebRequest.getRedirectorName()

setAutomaticSession

public void setAutomaticSession(boolean isAutomaticSession)

Parameters:
isAutomaticSession - whether the redirector servlet will automatically create the HTTP session or not. Default is true.
See Also:
WebRequest.setAutomaticSession(boolean)

getAutomaticSession

public boolean getAutomaticSession()

Returns:
true if session will be automatically created for the user or false otherwise.
See Also:
WebRequest.getAutomaticSession()

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.
See Also:
WebRequest.setURL(String, String, String, String, String)

getURL

public ServletURL getURL()

Returns:
the simulated URL
See Also:
WebRequest.getURL()

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
See Also:
WebRequest.getSessionCookie()


Copyright © 2001-2009 The Apache Software Foundation. All Rights Reserved.