Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD

## org.codehaus.groovy.grails.plugins.testing
[Groovy] Class GrailsMockHttpServletRequest

    java.lang.Object
      org.springframework.mock.web.MockHttpServletRequest
          org.codehaus.groovy.grails.plugins.testing.GrailsMockHttpServletRequest

All Implemented Interfaces:
  org.springframework.web.multipart.MultipartHttpServletRequest

    class GrailsMockHttpServletRequest
    extends org.springframework.mock.web.MockHttpServletRequest

A custom mock HTTP servlet request that provides the extra properties and methods normally injected by the "servlets" plugin.

Field Summary

Fields inherited from class org.springframework.mock.web.MockHttpServletRequest
DEFAULT_PROTOCOL, DEFAULT_SERVER_ADDR, DEFAULT_SERVER_NAME, DEFAULT_SERVER_PORT, DEFAULT_REMOTE_ADDR, DEFAULT_REMOTE_HOST, BASIC_AUTH, FORM_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH

Property Summary
`javax.servlet.AsyncContext` | `asyncContext`
`javax.servlet.DispatcherType` | `dispatcherType`
`boolean` | `invalidToken`
`org.springframework.util.MultiValueMap` | `multipartFiles`
`RequestMimeTypesApi` | `requestMimeTypesApi`

Method Summary
`void` | `addFile(org.springframework.web.multipart.MultipartFile file)` Add a file to this request.
`void` | `addFile(java.lang.String location, byte[] contents)` Add a file for the given location and bytes
`void` | `clearAttributes()`
`java.lang.Object` | `each(groovy.lang.Closure c)` Iterates over the request attributes.
`java.lang.Object` | `find(groovy.lang.Closure c)` Adds a "find()" method to the request that searches the request's attributes.
`java.lang.Object` | `findAll(groovy.lang.Closure c)` Like the find(Closure) method, this searches the request attributes.
`java.lang.Object` | `getAt(java.lang.String key)` Map-like access to request attributes, e.g. request["count"].
`org.springframework.web.multipart.MultipartFile` | `getFile(java.lang.String name)` {@inheritDoc }
`java.util.Map` | `getFileMap()` {@inheritDoc }
`java.util.Iterator` | `getFileNames()` {@inheritDoc }
`java.util.List` | `getFiles(java.lang.String name)` {@inheritDoc }
`java.lang.String` | `getForwardURI()` Implementation of the dynamic "forwardURI" property.
`java.lang.Object` | `getJSON()` Parses the request content as JSON using the JSON converter.
`org.springframework.util.MultiValueMap` | `getMultiFileMap()` {@inheritDoc }
`java.lang.String` | `getMultipartContentType(java.lang.String paramOrFileName)`
`HttpHeaders` | `getMultipartHeaders(java.lang.String paramOrFileName)`
`javax.servlet.http.Part` | `getPart(java.lang.String name)`
`java.util.Collection` | `getParts()`
`java.lang.Object` | `getProperty(java.lang.String name)` Property access for request attributes.
`HttpHeaders` | `getRequestHeaders()`
`org.springframework.http.HttpMethod` | `getRequestMethod()`
`java.lang.Object` | `getXML()` Parses the request content as XML using XmlSlurper and returns the GPath result object.
`boolean` | `isAsyncStarted()`
`boolean` | `isAsyncSupported()`
`boolean` | `isGet()`
`boolean` | `isPost()`
`boolean` | `isXhr()` Indicates whether this is an AJAX request or not (as far as Grails is concerned).
`void` | `makeAjaxRequest()` Makes this request an AJAX request as Grails understands it.
`void` | `putAt(java.lang.String key, java.lang.Object val)` Map-like setting of request attributes, e.g. request["count"] = 10.
`void` | `setFormat(java.lang.String format)` Sets the request format to use
`void` | `setForwardURI(java.lang.String uri)` Sets the "forwardURI" property for the request.
`void` | `setJSON(java.lang.Object sourceJson)`
`void` | `setJson(java.lang.Object sourceJson)` Sets the body of the request to be a json packet
`java.lang.String` | `setMultipartContentType(java.lang.String paramOrFileName, java.lang.String contentType)`
`HttpHeaders` | `setMultipartHeaders(java.lang.String paramOrFileName, HttpHeaders headers)`
`void` | `setProperty(java.lang.String name, java.lang.Object value)` Property setting of request attributes.
`void` | `setRequestHeaders(HttpHeaders headers)`
`org.springframework.http.HttpMethod` | `setRequestMethod(org.springframework.http.HttpMethod method)`
`void` | `setXML(java.lang.Object sourceXml)`
`void` | `setXml(java.lang.Object sourceXml)` Sets the body of the request to be an XML packet
`javax.servlet.AsyncContext` | `startAsync()`
`javax.servlet.AsyncContext` | `startAsync(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse)`

Methods inherited from class org.springframework.mock.web.MockHttpServletRequest
org.springframework.mock.web.MockHttpServletRequest#getMethod(), org.springframework.mock.web.MockHttpServletRequest#close(), org.springframework.mock.web.MockHttpServletRequest#getScheme(), org.springframework.mock.web.MockHttpServletRequest#getProtocol(), org.springframework.mock.web.MockHttpServletRequest#getInputStream(), org.springframework.mock.web.MockHttpServletRequest#setMethod(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getAttribute(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getContentType(), org.springframework.mock.web.MockHttpServletRequest#invalidate(), org.springframework.mock.web.MockHttpServletRequest#setParameter(java.lang.String, [Ljava.lang.String;), org.springframework.mock.web.MockHttpServletRequest#setParameter(java.lang.String, java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getParameter(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getContentLength(), org.springframework.mock.web.MockHttpServletRequest#setContentType(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getHeaders(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#login(java.lang.String, java.lang.String), org.springframework.mock.web.MockHttpServletRequest#logout(), org.springframework.mock.web.MockHttpServletRequest#isActive(), org.springframework.mock.web.MockHttpServletRequest#getLocale(), org.springframework.mock.web.MockHttpServletRequest#setParameters(java.util.Map), org.springframework.mock.web.MockHttpServletRequest#setAttribute(java.lang.String, java.lang.Object), org.springframework.mock.web.MockHttpServletRequest#getLocalPort(), org.springframework.mock.web.MockHttpServletRequest#getReader(), org.springframework.mock.web.MockHttpServletRequest#getHeader(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getLocalName(), org.springframework.mock.web.MockHttpServletRequest#removeAttribute(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setProtocol(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#addHeader(java.lang.String, java.lang.Object), org.springframework.mock.web.MockHttpServletRequest#removeParameter(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getCookies(), org.springframework.mock.web.MockHttpServletRequest#getAttributeNames(), org.springframework.mock.web.MockHttpServletRequest#authenticate(javax.servlet.http.HttpServletResponse), org.springframework.mock.web.MockHttpServletRequest#getUserPrincipal(), org.springframework.mock.web.MockHttpServletRequest#isSecure(), org.springframework.mock.web.MockHttpServletRequest#getSession(), org.springframework.mock.web.MockHttpServletRequest#getSession(boolean), org.springframework.mock.web.MockHttpServletRequest#getRemotePort(), org.springframework.mock.web.MockHttpServletRequest#setContent([B), org.springframework.mock.web.MockHttpServletRequest#getQueryString(), org.springframework.mock.web.MockHttpServletRequest#setScheme(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setQueryString(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#addParameter(java.lang.String, java.lang.String), org.springframework.mock.web.MockHttpServletRequest#addParameter(java.lang.String, [Ljava.lang.String;), org.springframework.mock.web.MockHttpServletRequest#setLocalName(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getServletContext(), org.springframework.mock.web.MockHttpServletRequest#getContextPath(), org.springframework.mock.web.MockHttpServletRequest#getParameterNames(), org.springframework.mock.web.MockHttpServletRequest#getServletPath(), org.springframework.mock.web.MockHttpServletRequest#getPathInfo(), org.springframework.mock.web.MockHttpServletRequest#getRequestURI(), org.springframework.mock.web.MockHttpServletRequest#getCharacterEncoding(), org.springframework.mock.web.MockHttpServletRequest#getAuthType(), org.springframework.mock.web.MockHttpServletRequest#getDateHeader(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getHeaderNames(), org.springframework.mock.web.MockHttpServletRequest#getIntHeader(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getPathTranslated(), org.springframework.mock.web.MockHttpServletRequest#getRemoteUser(), org.springframework.mock.web.MockHttpServletRequest#isUserInRole(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getRequestedSessionId(), org.springframework.mock.web.MockHttpServletRequest#getRequestURL(), org.springframework.mock.web.MockHttpServletRequest#isRequestedSessionIdValid(), org.springframework.mock.web.MockHttpServletRequest#isRequestedSessionIdFromCookie(), org.springframework.mock.web.MockHttpServletRequest#isRequestedSessionIdFromURL(), org.springframework.mock.web.MockHttpServletRequest#isRequestedSessionIdFromUrl(), org.springframework.mock.web.MockHttpServletRequest#setCharacterEncoding(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getParameterValues(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getParameterMap(), org.springframework.mock.web.MockHttpServletRequest#getServerName(), org.springframework.mock.web.MockHttpServletRequest#getServerPort(), org.springframework.mock.web.MockHttpServletRequest#getRemoteAddr(), org.springframework.mock.web.MockHttpServletRequest#getRemoteHost(), org.springframework.mock.web.MockHttpServletRequest#getLocales(), org.springframework.mock.web.MockHttpServletRequest#getRequestDispatcher(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getRealPath(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#getLocalAddr(), org.springframework.mock.web.MockHttpServletRequest#setSecure(boolean), org.springframework.mock.web.MockHttpServletRequest#clearAttributes(), org.springframework.mock.web.MockHttpServletRequest#addParameters(java.util.Map), org.springframework.mock.web.MockHttpServletRequest#removeAllParameters(), org.springframework.mock.web.MockHttpServletRequest#setServerName(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setServerPort(int), org.springframework.mock.web.MockHttpServletRequest#setRemoteAddr(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setRemoteHost(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#addPreferredLocale(java.util.Locale), org.springframework.mock.web.MockHttpServletRequest#setRemotePort(int), org.springframework.mock.web.MockHttpServletRequest#setLocalAddr(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setLocalPort(int), org.springframework.mock.web.MockHttpServletRequest#setAuthType(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setCookies([Ljavax.servlet.http.Cookie;), org.springframework.mock.web.MockHttpServletRequest#setPathInfo(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setContextPath(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setRemoteUser(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#addUserRole(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setUserPrincipal(java.security.Principal), org.springframework.mock.web.MockHttpServletRequest#setRequestedSessionId(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setRequestURI(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setServletPath(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#setSession(javax.servlet.http.HttpSession), org.springframework.mock.web.MockHttpServletRequest#setRequestedSessionIdValid(boolean), org.springframework.mock.web.MockHttpServletRequest#setRequestedSessionIdFromCookie(boolean), org.springframework.mock.web.MockHttpServletRequest#setRequestedSessionIdFromURL(boolean), org.springframework.mock.web.MockHttpServletRequest#wait(), org.springframework.mock.web.MockHttpServletRequest#wait(long), org.springframework.mock.web.MockHttpServletRequest#wait(long, int), org.springframework.mock.web.MockHttpServletRequest#equals(java.lang.Object), org.springframework.mock.web.MockHttpServletRequest#toString(), org.springframework.mock.web.MockHttpServletRequest#hashCode(), org.springframework.mock.web.MockHttpServletRequest#getClass(), org.springframework.mock.web.MockHttpServletRequest#notify(), org.springframework.mock.web.MockHttpServletRequest#notifyAll(), org.springframework.mock.web.MockHttpServletRequest#getParts(), org.springframework.mock.web.MockHttpServletRequest#getPart(java.lang.String), org.springframework.mock.web.MockHttpServletRequest#startAsync(javax.servlet.ServletRequest, javax.servlet.ServletResponse), org.springframework.mock.web.MockHttpServletRequest#startAsync(), org.springframework.mock.web.MockHttpServletRequest#isAsyncStarted(), org.springframework.mock.web.MockHttpServletRequest#isAsyncSupported(), org.springframework.mock.web.MockHttpServletRequest#getAsyncContext(), org.springframework.mock.web.MockHttpServletRequest#getDispatcherType()

Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Property Detail

### asyncContext

    javax.servlet.AsyncContext asyncContext

### dispatcherType

    javax.servlet.DispatcherType dispatcherType

### invalidToken

    boolean invalidToken

### multipartFiles

    org.springframework.util.MultiValueMap multipartFiles

### requestMimeTypesApi

    @ApiDelegate(HttpServletRequest)
    RequestMimeTypesApi requestMimeTypesApi

Method Detail

### addFile

    void addFile(org.springframework.web.multipart.MultipartFile file)

  Add a file to this request. The parameter name from the multipart form is taken from the org.springframework.web.multipart.MultipartFile#getName().
  Parameters:
    `file` - multipart file to be added

### addFile

    void addFile(java.lang.String location, byte[] contents)

  Add a file for the given location and bytes
  Parameters:
    `location` - The location
    `contents` - The bytes

### clearAttributes

    @Override
    void clearAttributes()

### each

    java.lang.Object each(groovy.lang.Closure c)

  Iterates over the request attributes.

### find

    java.lang.Object find(groovy.lang.Closure c)

  Adds a "find()" method to the request that searches the request's attributes. Returns the first attribute for which the closure returns `true`, just like the normal Groovy find() method.

### findAll

    java.lang.Object findAll(groovy.lang.Closure c)

  Like the find(Closure) method, this searches the request attributes. Returns all the attributes that match the closure conditions.

### getAt

    java.lang.Object getAt(java.lang.String key)

  Map-like access to request attributes, e.g. request["count"].

### getFile

    org.springframework.web.multipart.MultipartFile getFile(java.lang.String name)

  {
  inheritDoc:
    }

### getFileMap

    java.util.Map getFileMap()

  {
  inheritDoc:
    }

### getFileNames

    java.util.Iterator getFileNames()

  {
  inheritDoc:
    }

### getFiles

    java.util.List getFiles(java.lang.String name)

  {
  inheritDoc:
    }

### getForwardURI

    java.lang.String getForwardURI()

  Implementation of the dynamic "forwardURI" property.

### getJSON

    java.lang.Object getJSON()

  Parses the request content as JSON using the JSON converter. Throws an exception if there is no content or the content is not valid JSON.

### getMultiFileMap

    org.springframework.util.MultiValueMap getMultiFileMap()

  {
  inheritDoc:
    }

### getMultipartContentType

    java.lang.String getMultipartContentType(java.lang.String paramOrFileName)

### getMultipartHeaders

    HttpHeaders getMultipartHeaders(java.lang.String paramOrFileName)

### getPart

    javax.servlet.http.Part getPart(java.lang.String name)

### getParts

    java.util.Collection getParts()

### getProperty

    java.lang.Object getProperty(java.lang.String name)

  Property access for request attributes.

### getRequestHeaders

    HttpHeaders getRequestHeaders()

### getRequestMethod

    org.springframework.http.HttpMethod getRequestMethod()

### getXML

    java.lang.Object getXML()

  Parses the request content as XML using XmlSlurper and returns the GPath result object. Throws an exception if there is no content or the content is not valid XML.

### isAsyncStarted

    boolean isAsyncStarted()

### isAsyncSupported

    boolean isAsyncSupported()

### isGet

    boolean isGet()

### isPost

    boolean isPost()

### isXhr

    boolean isXhr()

  Indicates whether this is an AJAX request or not (as far as Grails is concerned). Returns `true` if it is an AJAX request, otherwise `false`.

### makeAjaxRequest

    void makeAjaxRequest()

  Makes this request an AJAX request as Grails understands it. This cannot be undone, so if you need a non-AJAX request you will have to create a new instance.

### putAt

    void putAt(java.lang.String key, java.lang.Object val)

  Map-like setting of request attributes, e.g. request["count"] = 10.

### setFormat

    void setFormat(java.lang.String format)

  Sets the request format to use
  Parameters:
    `format` - The request format

### setForwardURI

    void setForwardURI(java.lang.String uri)

  Sets the "forwardURI" property for the request.

### setJSON

    void setJSON(java.lang.Object sourceJson)

### setJson

    void setJson(java.lang.Object sourceJson)

  Sets the body of the request to be a json packet
  Parameters:
    `sourceJson` - The source json

### setMultipartContentType

    java.lang.String setMultipartContentType(java.lang.String paramOrFileName, java.lang.String contentType)

### setMultipartHeaders

    HttpHeaders setMultipartHeaders(java.lang.String paramOrFileName, HttpHeaders headers)

### setProperty

    void setProperty(java.lang.String name, java.lang.Object value)

  Property setting of request attributes.

### setRequestHeaders

    void setRequestHeaders(HttpHeaders headers)

### setRequestMethod

    org.springframework.http.HttpMethod setRequestMethod(org.springframework.http.HttpMethod method)

### setXML

    void setXML(java.lang.Object sourceXml)

### setXml

    void setXml(java.lang.Object sourceXml)

  Sets the body of the request to be an XML packet
  Parameters:
    sourceXml

### startAsync

    javax.servlet.AsyncContext startAsync()

### startAsync

    javax.servlet.AsyncContext startAsync(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse)

Groovy Documentation