Applied to a unit test to test controllers.
Type | Name and description |
---|---|
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 |
Constructor and description |
---|
ControllerUnitTestMixin
(java.util.Set<java.lang.String> features) |
ControllerUnitTestMixin
() |
Type | Name and description |
---|---|
protected GrailsClass |
createAndEnhance(java.lang.Class controllerClass) |
FlashScope |
getFlash() The Grails 'flash' object @return |
java.util.Map<java.lang.String, java.lang.String> |
getGroovyPages() |
java.util.Map |
getModel() @return The model of the current controller |
GrailsParameterMap |
getParams() The Grails 'params' object which is an instance of GrailsParameterMap |
GrailsMockHttpServletRequest |
getRequest() |
GrailsMockHttpServletResponse |
getResponse() |
org.springframework.mock.web.MockServletContext |
getServletContext() |
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.util.Map<java.lang.String, java.lang.String> |
getViews() |
GrailsWebRequest |
getWebRequest() |
java.lang.Object |
mockCommandObject(java.lang.Class commandClass) Mocks a Grails command object providing the necessary validation behavior and returning the instance |
T |
mockController(java.lang.Class<T> controllerClass) Mocks a Grails controller class, providing the needed behavior and defining it in the ApplicationContext |
T |
testFor(java.lang.Class<T> controllerClass) Signifies that the given controller class is the class under test |
Methods inherited from class | Name |
---|---|
class GrailsUnitTestMixin |
defineBeans, getApplicationContext, getConfig, getGrailsApplication, getMainContext, getMessageSource, mockCodec, mockFor, mockForConstraintsTests, shouldFail, shouldFail |
class TestMixinRuntimeSupport |
getFeatures, getRuntime, setRuntime, setTestClass |
class groovy.lang.GroovyObjectSupport |
groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll() |
The Grails 'flash' object
The Grails 'params' object which is an instance of GrailsParameterMap
The org.springframework.mock.web.MockHttpSession instance
Mocks a Grails command object providing the necessary validation behavior and returning the instance
commandClass
- The command classMocks a Grails controller class, providing the needed behavior and defining it in the ApplicationContext
controllerClass
- The controller classSignifies that the given controller class is the class under test
controllerClass
- The controller classGroovy Documentation