MockHttpServletRequest (Struts 1.3.10 API)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts.mock
Class MockHttpServletRequest

    java.lang.Object
      org.apache.struts.mock.MockHttpServletRequest

All Implemented Interfaces:
  HttpServletRequest, ServletRequest

    public class MockHttpServletRequest

extends Object
implements HttpServletRequest

Mock HttpServletRequest object for low-level unit tests of Struts controller components. Coarser grained tests should be implemented in terms of the Cactus framework, instead of the mock object classes.

WARNING - Only the minimal set of methods needed to create unit tests is provided, plus additional methods to configure this object as necessary. Methods for unsupported operations will throw `UnsupportedOperationException`.

WARNING - Because unit tests operate in a single threaded environment, no synchronization is performed.

Version:
  $Rev: 471754 $ $Date: 2006-11-06 08:55:09 -0600 (Mon, 06 Nov 2006) $

Field Summary
`protected HashMap` | `attributes` The set of request attributes.
`protected String` | `contentType` The Content Type for this request.
`protected String` | `contextPath` The context path for this request.
`protected Locale` | `locale` The preferred locale for this request.
`protected String` | `method` The HTTP request method.
`protected HashMap` | `parameters` The set of arrays of parameter values, keyed by parameter name.
`protected String` | `pathInfo` The extra path information for this request.
`protected Principal` | `principal` The authenticated user for this request.
`protected String` | `queryString` The query string for this request.
`protected String` | `servletPath` The servlet path for this request.
`protected HttpSession` | `session` The HttpSession with which we are associated.

Fields inherited from interface javax.servlet.http.HttpServletRequest
`BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH`

Constructor Summary
`MockHttpServletRequest()`
`MockHttpServletRequest(HttpSession session)`
`MockHttpServletRequest(String contextPath, String servletPath, String pathInfo, String queryString)`
`MockHttpServletRequest(String contextPath, String servletPath, String pathInfo, String queryString, HttpSession session)`

Method Summary
`void` | `addParameter(String name, String value)`
`Object` | `getAttribute(String name)`
`Enumeration` | `getAttributeNames()`
`String` | `getAuthType()`
`String` | `getCharacterEncoding()`
`int` | `getContentLength()`
`String` | `getContentType()`
`String` | `getContextPath()`
`Cookie[]` | `getCookies()`
`long` | `getDateHeader(String name)`
`String` | `getHeader(String name)`
`Enumeration` | `getHeaderNames()`
`Enumeration` | `getHeaders(String name)`
`ServletInputStream` | `getInputStream()`
`int` | `getIntHeader(String name)`
`Locale` | `getLocale()`
`Enumeration` | `getLocales()`
`String` | `getMethod()`
`String` | `getParameter(String name)`
`Map` | `getParameterMap()`
`Enumeration` | `getParameterNames()`
`String[]` | `getParameterValues(String name)`
`String` | `getPathInfo()`
`String` | `getPathTranslated()`
`String` | `getProtocol()`
`String` | `getQueryString()`
`BufferedReader` | `getReader()`
`String` | `getRealPath(String path)`
`String` | `getRemoteAddr()`
`String` | `getRemoteHost()`
`String` | `getRemoteUser()`
`RequestDispatcher` | `getRequestDispatcher(String path)`
`String` | `getRequestedSessionId()`
`String` | `getRequestURI()`
`StringBuffer` | `getRequestURL()`
`String` | `getScheme()`
`String` | `getServerName()`
`int` | `getServerPort()`
`String` | `getServletPath()`
`HttpSession` | `getSession()`
`HttpSession` | `getSession(boolean create)`
`Principal` | `getUserPrincipal()`
`boolean` | `isRequestedSessionIdFromCookie()`
`boolean` | `isRequestedSessionIdFromUrl()`
`boolean` | `isRequestedSessionIdFromURL()`
`boolean` | `isRequestedSessionIdValid()`
`boolean` | `isSecure()`
`boolean` | `isUserInRole(String role)`
`void` | `removeAttribute(String name)`
`void` | `setAttribute(String name, Object value)`
`void` | `setCharacterEncoding(String name)`
`void` | `setContentType(String contentType)`
`void` | `setHttpSession(HttpSession session)`
`void` | `setLocale(Locale locale)`
`void` | `setMethod(String method)`
`void` | `setPathElements(String contextPath, String servletPath, String pathInfo, String queryString)`
`void` | `setUserPrincipal(Principal principal)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### attributes

    protected HashMap attributes

  The set of request attributes.

### contextPath

    protected String contextPath

  The context path for this request.

### locale

    protected Locale locale

  The preferred locale for this request.

### parameters

    protected HashMap parameters

  The set of arrays of parameter values, keyed by parameter name.

### pathInfo

    protected String pathInfo

  The extra path information for this request. v *

### principal

    protected Principal principal

  The authenticated user for this request.

### queryString

    protected String queryString

  The query string for this request.

### servletPath

    protected String servletPath

  The servlet path for this request.

### session

    protected HttpSession session

  The HttpSession with which we are associated.

### method

    protected String method

  The HTTP request method.

### contentType

    protected String contentType

  The Content Type for this request.

Constructor Detail

### MockHttpServletRequest

    public MockHttpServletRequest()

### MockHttpServletRequest

    public MockHttpServletRequest(HttpSession session)

### MockHttpServletRequest

    public MockHttpServletRequest(String contextPath,
                                  String servletPath,
                                  String pathInfo,
                                  String queryString)

### MockHttpServletRequest

    public MockHttpServletRequest(String contextPath,
                                  String servletPath,
                                  String pathInfo,
                                  String queryString,
                                  HttpSession session)

Method Detail

### addParameter

    public void addParameter(String name,
                             String value)

### setHttpSession

    public void setHttpSession(HttpSession session)

### setLocale

    public void setLocale(Locale locale)

### setMethod

    public void setMethod(String method)

### setContentType

    public void setContentType(String contentType)

### setPathElements

    public void setPathElements(String contextPath,
                                String servletPath,
                                String pathInfo,
                                String queryString)

### setUserPrincipal

    public void setUserPrincipal(Principal principal)

### getAuthType

    public String getAuthType()

  Specified by:
    `getAuthType` in interface `HttpServletRequest`

### getContextPath

    public String getContextPath()

  Specified by:
    `getContextPath` in interface `HttpServletRequest`

### getCookies

    public Cookie[] getCookies()

  Specified by:
    `getCookies` in interface `HttpServletRequest`

### getDateHeader

    public long getDateHeader(String name)

  Specified by:
    `getDateHeader` in interface `HttpServletRequest`

### getHeader

    public String getHeader(String name)

  Specified by:
    `getHeader` in interface `HttpServletRequest`

### getHeaderNames

    public Enumeration getHeaderNames()

  Specified by:
    `getHeaderNames` in interface `HttpServletRequest`

### getHeaders

    public Enumeration getHeaders(String name)

  Specified by:
    `getHeaders` in interface `HttpServletRequest`

### getIntHeader

    public int getIntHeader(String name)

  Specified by:
    `getIntHeader` in interface `HttpServletRequest`

### getMethod

    public String getMethod()

  Specified by:
    `getMethod` in interface `HttpServletRequest`

### getPathInfo

    public String getPathInfo()

  Specified by:
    `getPathInfo` in interface `HttpServletRequest`

### getPathTranslated

    public String getPathTranslated()

  Specified by:
    `getPathTranslated` in interface `HttpServletRequest`

### getQueryString

    public String getQueryString()

  Specified by:
    `getQueryString` in interface `HttpServletRequest`

### getRemoteUser

    public String getRemoteUser()

  Specified by:
    `getRemoteUser` in interface `HttpServletRequest`

### getRequestedSessionId

    public String getRequestedSessionId()

  Specified by:
    `getRequestedSessionId` in interface `HttpServletRequest`

### getRequestURI

    public String getRequestURI()

  Specified by:
    `getRequestURI` in interface `HttpServletRequest`

### getRequestURL

    public StringBuffer getRequestURL()

  Specified by:
    `getRequestURL` in interface `HttpServletRequest`

### getServletPath

    public String getServletPath()

  Specified by:
    `getServletPath` in interface `HttpServletRequest`

### getSession

    public HttpSession getSession()

  Specified by:
    `getSession` in interface `HttpServletRequest`

### getSession

    public HttpSession getSession(boolean create)

  Specified by:
    `getSession` in interface `HttpServletRequest`

### getUserPrincipal

    public Principal getUserPrincipal()

  Specified by:
    `getUserPrincipal` in interface `HttpServletRequest`

### isRequestedSessionIdFromCookie

    public boolean isRequestedSessionIdFromCookie()

  Specified by:
    `isRequestedSessionIdFromCookie` in interface `HttpServletRequest`

### isRequestedSessionIdFromUrl

    public boolean isRequestedSessionIdFromUrl()

  Specified by:
    `isRequestedSessionIdFromUrl` in interface `HttpServletRequest`

### isRequestedSessionIdFromURL

    public boolean isRequestedSessionIdFromURL()

  Specified by:
    `isRequestedSessionIdFromURL` in interface `HttpServletRequest`

### isRequestedSessionIdValid

    public boolean isRequestedSessionIdValid()

  Specified by:
    `isRequestedSessionIdValid` in interface `HttpServletRequest`

### isUserInRole

    public boolean isUserInRole(String role)

  Specified by:
    `isUserInRole` in interface `HttpServletRequest`

### getAttribute

    public Object getAttribute(String name)

  Specified by:
    `getAttribute` in interface `ServletRequest`

### getAttributeNames

    public Enumeration getAttributeNames()

  Specified by:
    `getAttributeNames` in interface `ServletRequest`

### getCharacterEncoding

    public String getCharacterEncoding()

  Specified by:
    `getCharacterEncoding` in interface `ServletRequest`

### getContentLength

    public int getContentLength()

  Specified by:
    `getContentLength` in interface `ServletRequest`

### getContentType

    public String getContentType()

  Specified by:
    `getContentType` in interface `ServletRequest`

### getInputStream

    public ServletInputStream getInputStream()

  Specified by:
    `getInputStream` in interface `ServletRequest`

### getLocale

    public Locale getLocale()

  Specified by:
    `getLocale` in interface `ServletRequest`

### getLocales

    public Enumeration getLocales()

  Specified by:
    `getLocales` in interface `ServletRequest`

### getParameter

    public String getParameter(String name)

  Specified by:
    `getParameter` in interface `ServletRequest`

### getParameterMap

    public Map getParameterMap()

  Specified by:
    `getParameterMap` in interface `ServletRequest`

### getParameterNames

    public Enumeration getParameterNames()

  Specified by:
    `getParameterNames` in interface `ServletRequest`

### getParameterValues

    public String[] getParameterValues(String name)

  Specified by:
    `getParameterValues` in interface `ServletRequest`

### getProtocol

    public String getProtocol()

  Specified by:
    `getProtocol` in interface `ServletRequest`

### getReader

    public BufferedReader getReader()

  Specified by:
    `getReader` in interface `ServletRequest`

### getRealPath

    public String getRealPath(String path)

  Specified by:
    `getRealPath` in interface `ServletRequest`

### getRemoteAddr

    public String getRemoteAddr()

  Specified by:
    `getRemoteAddr` in interface `ServletRequest`

### getRemoteHost

    public String getRemoteHost()

  Specified by:
    `getRemoteHost` in interface `ServletRequest`

### getRequestDispatcher

    public RequestDispatcher getRequestDispatcher(String path)

  Specified by:
    `getRequestDispatcher` in interface `ServletRequest`

### getScheme

    public String getScheme()

  Specified by:
    `getScheme` in interface `ServletRequest`

### getServerName

    public String getServerName()

  Specified by:
    `getServerName` in interface `ServletRequest`

### getServerPort

    public int getServerPort()

  Specified by:
    `getServerPort` in interface `ServletRequest`

### isSecure

    public boolean isSecure()

  Specified by:
    `isSecure` in interface `ServletRequest`

### removeAttribute

    public void removeAttribute(String name)

  Specified by:
    `removeAttribute` in interface `ServletRequest`

### setAttribute

    public void setAttribute(String name,
                             Object value)

  Specified by:
    `setAttribute` in interface `ServletRequest`

### setCharacterEncoding

    public void setCharacterEncoding(String name)

  Specified by:
    `setCharacterEncoding` in interface `ServletRequest`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.