com.google.appengine.tools.development.testing

## Class FakeHttpServletRequest

- java.lang.Object
- - com.google.appengine.tools.development.testing.FakeHttpServletRequest

-     public class FakeHttpServletRequest
      extends java.lang.Object

  Simple fake implementation of `HttpServletRequest`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected byte[]` | `bodyData`
    `protected java.lang.String` | `characterEncoding`
    `protected java.lang.String` | `contentType`
    `protected boolean` | `getInputStreamCalled`
    `protected boolean` | `getReaderCalled`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FakeHttpServletRequest()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addParameter(java.lang.String key, java.lang.String value)`
    `boolean` | `authenticate(HttpServletResponse httpServletResponse)`
    `java.lang.String` | `changeSessionId()`
    `AsyncContext` | `getAsyncContext()`
    `java.lang.Object` | `getAttribute(java.lang.String name)`
    `java.util.Enumeration<java.lang.String>` | `getAttributeNames()`
    `java.lang.String` | `getAuthType()`
    `java.lang.String` | `getCharacterEncoding()`
    `int` | `getContentLength()`
    `long` | `getContentLengthLong()`
    `java.lang.String` | `getContentType()`
    `java.lang.String` | `getContextPath()`
    `Cookie[]` | `getCookies()`
    `long` | `getDateHeader(java.lang.String name)`
    `DispatcherType` | `getDispatcherType()`
    `java.lang.String` | `getHeader(java.lang.String name)`
    `java.util.Enumeration<java.lang.String>` | `getHeaderNames()`
    `java.util.Enumeration<java.lang.String>` | `getHeaders(java.lang.String name)`
    `ServletInputStream` | `getInputStream()` Get the body of the request (i.e.
    `int` | `getIntHeader(java.lang.String name)`
    `java.lang.String` | `getLocalAddr()`
    `java.util.Locale` | `getLocale()`
    `java.util.Enumeration<java.util.Locale>` | `getLocales()`
    `java.lang.String` | `getLocalName()`
    `int` | `getLocalPort()`
    `java.lang.String` | `getMethod()`
    `java.lang.String` | `getParameter(java.lang.String name)`
    `java.util.Map<java.lang.String,java.lang.String[]>` | `getParameterMap()`
    `java.util.Enumeration<java.lang.String>` | `getParameterNames()`
    `java.lang.String[]` | `getParameterValues(java.lang.String name)`
    `Part` | `getPart(java.lang.String s)`
    `java.util.Collection<Part>` | `getParts()`
    `java.lang.String` | `getPathInfo()`
    `java.lang.String` | `getPathTranslated()`
    `java.lang.String` | `getProtocol()`
    `java.lang.String` | `getQueryString()`
    `java.io.BufferedReader` | `getReader()`
    `java.lang.String` | `getRealPath(java.lang.String path)` Deprecated.
    `java.lang.String` | `getRemoteAddr()`
    `java.lang.String` | `getRemoteHost()`
    `int` | `getRemotePort()`
    `java.lang.String` | `getRemoteUser()`
    `RequestDispatcher` | `getRequestDispatcher(java.lang.String path)`
    `java.lang.String` | `getRequestedSessionId()`
    `java.lang.String` | `getRequestURI()`
    `java.lang.StringBuffer` | `getRequestURL()`
    `java.lang.String` | `getScheme()`
    `java.lang.String` | `getServerName()`
    `int` | `getServerPort()`
    `ServletContext` | `getServletContext()`
    `java.lang.String` | `getServletPath()`
    `HttpSession` | `getSession()`
    `HttpSession` | `getSession(boolean create)`
    `java.security.Principal` | `getUserPrincipal()`
    `boolean` | `isAsyncStarted()`
    `boolean` | `isAsyncSupported()`
    `boolean` | `isRequestedSessionIdFromCookie()`
    `boolean` | `isRequestedSessionIdFromUrl()` Deprecated.
    `boolean` | `isRequestedSessionIdFromURL()`
    `boolean` | `isRequestedSessionIdValid()`
    `boolean` | `isSecure()`
    `boolean` | `isUserInRole(java.lang.String role)`
    `void` | `login(java.lang.String s, java.lang.String s1)`
    `void` | `logout()`
    `void` | `removeAttribute(java.lang.String name)`
    `void` | `setAttribute(java.lang.String name, java.lang.Object value)`
    `void` | `setCharacterEncoding(java.lang.String env)`
    `void` | `setContentType(java.lang.String contentType)` Sets the content type.
    `void` | `setHeader(java.lang.String key, java.lang.String value)`
    `void` | `setHostName(java.lang.String hostName)`
    `void` | `setMethod(java.lang.String name)`
    `void` | `setParametersFromQueryString(java.lang.String qs)`
    `void` | `setPort(int port)`
    `void` | `setPostData(byte[] data)` Specify the mock POST data in raw binary format.
    `void` | `setPostData(java.lang.String postString, java.nio.charset.Charset encoding)` Specify the mock POST data.
    `void` | `setPostData(java.lang.String postString, java.lang.String encoding)` Specify the mock POST data.
    `AsyncContext` | `startAsync()`
    `AsyncContext` | `startAsync(ServletRequest servletRequest, ServletResponse servletResponse)`
    `<T extends HttpUpgradeHandler> T` | `upgrade(java.lang.Class<T> aClass)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### contentType

          protected java.lang.String contentType

    - #### bodyData

          protected byte[] bodyData

    - #### characterEncoding

          protected java.lang.String characterEncoding

    - #### getReaderCalled

          protected boolean getReaderCalled

    - #### getInputStreamCalled

          protected boolean getInputStreamCalled

  - ### Constructor Detail

    - #### FakeHttpServletRequest

          public FakeHttpServletRequest()

  - ### Method Detail

    - #### getAttribute

          public java.lang.Object getAttribute(java.lang.String name)

    - #### getAttributeNames

          public java.util.Enumeration<java.lang.String> getAttributeNames()

    - #### getCharacterEncoding

          public java.lang.String getCharacterEncoding()

    - #### getContentLength

          public int getContentLength()

    - #### getContentLengthLong

          public long getContentLengthLong()

    - #### getContentType

          public java.lang.String getContentType()

    - #### getInputStream

          public ServletInputStream getInputStream()

      Get the body of the request (i.e. the body data) as a binary stream. As per Java docs, this OR getReader() may be called, but not both (attempting that will result in an IllegalStateException)

    - #### getLocalAddr

          public java.lang.String getLocalAddr()

    - #### getLocalName

          public java.lang.String getLocalName()

    - #### getLocalPort

          public int getLocalPort()

    - #### getServletContext

          public ServletContext getServletContext()

    - #### startAsync

          public AsyncContext startAsync()

    - #### startAsync

          public AsyncContext startAsync(ServletRequest servletRequest,
                                         ServletResponse servletResponse)

    - #### isAsyncStarted

          public boolean isAsyncStarted()

    - #### isAsyncSupported

          public boolean isAsyncSupported()

    - #### getAsyncContext

          public AsyncContext getAsyncContext()

    - #### getDispatcherType

          public DispatcherType getDispatcherType()

    - #### getLocale

          public java.util.Locale getLocale()

    - #### getLocales

          public java.util.Enumeration<java.util.Locale> getLocales()

    - #### getParameter

          public java.lang.String getParameter(java.lang.String name)

    - #### getParameterMap

          public java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()

    - #### getParameterNames

          public java.util.Enumeration<java.lang.String> getParameterNames()

    - #### getParameterValues

          public java.lang.String[] getParameterValues(java.lang.String name)

    - #### getProtocol

          public java.lang.String getProtocol()

    - #### getReader

          public java.io.BufferedReader getReader()

    - #### getRealPath

          @Deprecated
          public java.lang.String getRealPath(java.lang.String path)

      Deprecated.

    - #### getRemoteAddr

          public java.lang.String getRemoteAddr()

    - #### getRemoteHost

          public java.lang.String getRemoteHost()

    - #### getRemotePort

          public int getRemotePort()

    - #### getRequestDispatcher

          public RequestDispatcher getRequestDispatcher(java.lang.String path)

    - #### getScheme

          public java.lang.String getScheme()

    - #### getServerName

          public java.lang.String getServerName()

    - #### getServerPort

          public int getServerPort()

    - #### isSecure

          public boolean isSecure()

    - #### removeAttribute

          public void removeAttribute(java.lang.String name)

    - #### setAttribute

          public void setAttribute(java.lang.String name,
                                   java.lang.Object value)

    - #### setCharacterEncoding

          public void setCharacterEncoding(java.lang.String env)
                                    throws java.lang.UnsupportedOperationException

      Throws:
        `java.lang.UnsupportedOperationException`

    - #### getAuthType

          public java.lang.String getAuthType()

    - #### getContextPath

          public java.lang.String getContextPath()

    - #### getCookies

          public Cookie[] getCookies()

    - #### getDateHeader

          public long getDateHeader(java.lang.String name)

    - #### getHeader

          public java.lang.String getHeader(java.lang.String name)

    - #### getHeaderNames

          public java.util.Enumeration<java.lang.String> getHeaderNames()

    - #### getHeaders

          public java.util.Enumeration<java.lang.String> getHeaders(java.lang.String name)

    - #### getIntHeader

          public int getIntHeader(java.lang.String name)

    - #### getMethod

          public java.lang.String getMethod()

    - #### getPathInfo

          public java.lang.String getPathInfo()

    - #### getPathTranslated

          public java.lang.String getPathTranslated()

    - #### getQueryString

          public java.lang.String getQueryString()

    - #### getRemoteUser

          public java.lang.String getRemoteUser()

    - #### getRequestURI

          public java.lang.String getRequestURI()

    - #### getRequestURL

          public java.lang.StringBuffer getRequestURL()

    - #### getRequestedSessionId

          public java.lang.String getRequestedSessionId()

    - #### getServletPath

          public java.lang.String getServletPath()

    - #### getSession

          public HttpSession getSession()

    - #### changeSessionId

          public java.lang.String changeSessionId()

    - #### getSession

          public HttpSession getSession(boolean create)

    - #### getUserPrincipal

          public java.security.Principal getUserPrincipal()

    - #### isRequestedSessionIdFromCookie

          public boolean isRequestedSessionIdFromCookie()

    - #### isRequestedSessionIdFromURL

          public boolean isRequestedSessionIdFromURL()

    - #### isRequestedSessionIdFromUrl

          @Deprecated
          public boolean isRequestedSessionIdFromUrl()

      Deprecated.

    - #### authenticate

          public boolean authenticate(HttpServletResponse httpServletResponse)
                               throws java.io.IOException,
                                      ServletException

      Throws:
        `java.io.IOException`
        `ServletException`

    - #### login

          public void login(java.lang.String s,
                            java.lang.String s1)
                     throws ServletException

      Throws:
        `ServletException`

    - #### logout

          public void logout()
                      throws ServletException

      Throws:
        `ServletException`

    - #### getParts

          public java.util.Collection<Part> getParts()
                                              throws java.io.IOException,
                                                     ServletException

      Throws:
        `java.io.IOException`
        `ServletException`

    - #### getPart

          public Part getPart(java.lang.String s)
                       throws java.io.IOException,
                              ServletException

      Throws:
        `java.io.IOException`
        `ServletException`

    - #### upgrade

          public <T extends HttpUpgradeHandler> T upgrade(java.lang.Class<T> aClass)
                                                   throws java.io.IOException,
                                                          ServletException

      Throws:
        `java.io.IOException`
        `ServletException`

    - #### isRequestedSessionIdValid

          public boolean isRequestedSessionIdValid()

    - #### isUserInRole

          public boolean isUserInRole(java.lang.String role)

    - #### setParametersFromQueryString

          public void setParametersFromQueryString(java.lang.String qs)

    - #### setHostName

          public void setHostName(java.lang.String hostName)

    - #### setPort

          public void setPort(int port)

    - #### setHeader

          public void setHeader(java.lang.String key,
                                java.lang.String value)

    - #### addParameter

          public void addParameter(java.lang.String key,
                                   java.lang.String value)

    - #### setMethod

          public void setMethod(java.lang.String name)

    - #### setPostData

          public void setPostData(java.lang.String postString,
                                  java.nio.charset.Charset encoding)
                           throws java.io.UnsupportedEncodingException

      Specify the mock POST data.
      Parameters:
        `postString` - the mock post data
        `encoding` - format with which to encode mock post data
      Throws:
        `java.io.UnsupportedEncodingException`

    - #### setPostData

          public void setPostData(java.lang.String postString,
                                  java.lang.String encoding)
                           throws java.io.UnsupportedEncodingException

      Specify the mock POST data.
      Parameters:
        `postString` - the mock post data
        `encoding` - format with which to encode mock post data
      Throws:
        `java.io.UnsupportedEncodingException`

    - #### setPostData

          public void setPostData(byte[] data)

      Specify the mock POST data in raw binary format.

      This implicitly sets character encoding to not specified.

      Parameters:
        `data` - the mock post data; this is owned by the caller, so modifications made after this call will show up when the post data is read

    - #### setContentType

          public void setContentType(java.lang.String contentType)

      Sets the content type.
      Parameters:
        `contentType` - of the request.