Groovy Documentation

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

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

class GrailsMockHttpServletRequest
extends MockHttpServletRequest

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


Property Summary
boolean invalidToken

 
Method Summary
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"].

java.lang.String getForwardURI()

Implementation of the dynamic "forwardURI" property.

java.lang.Object getJSON()

Parses the request content as JSON using the JSON converter.

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

Property access for request attributes.

java.lang.Object getXML()

Parses the request content as XML using XmlSlurper and returns the GPath result object.

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 setForwardURI(java.lang.String uri)

Sets the "forwardURI" property for the request.

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

Property setting of request attributes.

 

Property Detail

invalidToken

boolean invalidToken


 
Method Detail

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"].


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.


getProperty

java.lang.Object getProperty(java.lang.String name)
Property access for request attributes.


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.


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.


setForwardURI

void setForwardURI(java.lang.String uri)
Sets the "forwardURI" property for the request.


setProperty

void setProperty(java.lang.String name, java.lang.Object value)
Property setting of request attributes.


 

Groovy Documentation