Groovy Documentation

grails.test.mixin.web
[Groovy] Class ControllerUnitTestMixin

java.lang.Object
  grails.test.mixin.support.GrailsUnitTestMixin
      grails.test.mixin.web.ControllerUnitTestMixin

class ControllerUnitTestMixin
extends GrailsUnitTestMixin

Applied to a unit test to test controllers.

Authors:
Graeme Rocher
Since:
2.0


Property Summary
static java.lang.String ALL_CONTENT_TYPE

static java.lang.String ATOM_XML_CONTENT_TYPE

static java.lang.String FORM_CONTENT_TYPE

static java.lang.String HAL_JSON_CONTENT_TYPE

static java.lang.String HAL_XML_CONTENT_TYPE

static java.lang.String HTML_CONTENT_TYPE

static java.lang.String JSON_CONTENT_TYPE

static java.lang.String MULTIPART_FORM_CONTENT_TYPE

static java.lang.String TEXT_JSON_CONTENT_TYPE

static java.lang.String TEXT_XML_CONTENT_TYPE

static java.lang.String XHTML_CONTENT_TYPE

static java.lang.String XML_CONTENT_TYPE

static java.util.Map groovyPages

Used to define additional GSP pages or templates where the key is the path to the template and the value is the contents of the template.

GrailsMockHttpServletRequest request

The GrailsMockHttpServletRequest object

GrailsMockHttpServletResponse response

The GrailsMockHttpServletResponse object

static org.springframework.mock.web.MockServletContext servletContext

The ServletContext

static java.util.Map views

Used to define additional GSP pages or templates where the key is the path to the template and the value is the contents of the template.

GrailsWebRequest webRequest

The GrailsWebRequest object

 
Method Summary
void bindGrailsWebRequest()

static void cleanupGrailsWeb()

void clearGrailsWebRequest()

static void configureGrailsWeb()

protected GrailsClass createAndEnhance(java.lang.Class controllerClass)

FlashScope getFlash()

The Grails 'flash' object @return

java.util.Map getModel()

@return The model of the current controller

GrailsParameterMap getParams()

The Grails 'params' object which is an instance of GrailsParameterMap

org.springframework.mock.web.MockHttpSession getSession()

The org.springframework.mock.web.MockHttpSession instance

int getStatus()

@return The status code of the response

java.lang.String getView()

@return The view of the current controller

java.lang.Object mockCommandObject(java.lang.Class commandClass)

Mocks a Grails command object providing the necessary validation behavior and returning the instance

java.lang.Object mockController(java.lang.Class controllerClass)

Mocks a Grails controller class, providing the needed behavior and defining it in the ApplicationContext

java.lang.Object testFor(java.lang.Class controllerClass)

Signifies that the given controller class is the class under test

 
Methods inherited from class GrailsUnitTestMixin
cleanupModifiedMetaClasses, defineBeans, deregisterMetaClassCleaner, initGrailsApplication, mockCodec, mockFor, mockForConstraintsTests, registerBeans, registerMetaClassRegistryWatcher, resetGrailsApplication, shouldFail, shouldFail, shutdownApplicationContext
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), 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

ALL_CONTENT_TYPE

static java.lang.String ALL_CONTENT_TYPE


ATOM_XML_CONTENT_TYPE

static java.lang.String ATOM_XML_CONTENT_TYPE


FORM_CONTENT_TYPE

static java.lang.String FORM_CONTENT_TYPE


HAL_JSON_CONTENT_TYPE

static java.lang.String HAL_JSON_CONTENT_TYPE


HAL_XML_CONTENT_TYPE

static java.lang.String HAL_XML_CONTENT_TYPE


HTML_CONTENT_TYPE

static java.lang.String HTML_CONTENT_TYPE


JSON_CONTENT_TYPE

static java.lang.String JSON_CONTENT_TYPE


MULTIPART_FORM_CONTENT_TYPE

static java.lang.String MULTIPART_FORM_CONTENT_TYPE


TEXT_JSON_CONTENT_TYPE

static java.lang.String TEXT_JSON_CONTENT_TYPE


TEXT_XML_CONTENT_TYPE

static java.lang.String TEXT_XML_CONTENT_TYPE


XHTML_CONTENT_TYPE

static java.lang.String XHTML_CONTENT_TYPE


XML_CONTENT_TYPE

static java.lang.String XML_CONTENT_TYPE


groovyPages

static java.util.Map groovyPages
Used to define additional GSP pages or templates where the key is the path to the template and the value is the contents of the template. Allows loading of templates without using the file system


request

GrailsMockHttpServletRequest request
The GrailsMockHttpServletRequest object


response

GrailsMockHttpServletResponse response
The GrailsMockHttpServletResponse object


servletContext

static org.springframework.mock.web.MockServletContext servletContext
The ServletContext


views

static java.util.Map views
Used to define additional GSP pages or templates where the key is the path to the template and the value is the contents of the template. Allows loading of templates without using the file system


webRequest

GrailsWebRequest webRequest
The GrailsWebRequest object


 
Method Detail

bindGrailsWebRequest

@org.junit.Before
@groovy.transform.CompileStatic
void bindGrailsWebRequest()


cleanupGrailsWeb

@org.junit.AfterClass
@groovy.transform.CompileStatic
static void cleanupGrailsWeb()


clearGrailsWebRequest

@org.junit.After
void clearGrailsWebRequest()


configureGrailsWeb

@org.junit.BeforeClass
static void configureGrailsWeb()


createAndEnhance

@groovy.transform.CompileStatic
protected GrailsClass createAndEnhance(java.lang.Class controllerClass)


getFlash

FlashScope getFlash()
The Grails 'flash' object
Returns:


getModel

java.util.Map getModel()
Returns:
The model of the current controller


getParams

GrailsParameterMap getParams()
The Grails 'params' object which is an instance of GrailsParameterMap


getSession

org.springframework.mock.web.MockHttpSession getSession()
The org.springframework.mock.web.MockHttpSession instance


getStatus

int getStatus()
Returns:
The status code of the response


getView

java.lang.String getView()
Returns:
The view of the current controller


mockCommandObject

java.lang.Object mockCommandObject(java.lang.Class commandClass)
Mocks a Grails command object providing the necessary validation behavior and returning the instance
Parameters:
commandClass - The command class
Returns:
The instance


mockController

java.lang.Object mockController(java.lang.Class controllerClass)
Mocks a Grails controller class, providing the needed behavior and defining it in the ApplicationContext
Parameters:
controllerClass - The controller class
Returns:
An instance of the controller


testFor

java.lang.Object testFor(java.lang.Class controllerClass)
Signifies that the given controller class is the class under test
Parameters:
controllerClass - The controller class
Returns:
an instance of the controller


 

Groovy Documentation