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

A mixin that can be applied to a unit test in order to test controllers.

Authors:
Graeme Rocher
Since:
2.0


Property Summary
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()

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

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, registerMetaClassRegistryWatcher, resetGrailsApplication, shouldFail, shouldFail, shutdownApplicationContext
 
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

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

@Before
void bindGrailsWebRequest()


cleanupGrailsWeb

@AfterClass
static void cleanupGrailsWeb()


clearGrailsWebRequest

@After
void clearGrailsWebRequest()


configureGrailsWeb

@BeforeClass
static void configureGrailsWeb()


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


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