A unit testing mixin to support the testing of Grails filter classes. This mixin provides a FiltersUnitTestMixin.mockFilters method to mock a filters class.
A typical usage pattern involves wrapping a call to controller in a call to the FiltersUnitTestMixin.withFilters method:
def controller = mockController(MyController)
mockFilters(MyFilters)
withFilters(action:"list") {
controller.list()
}
Constructor and description |
---|
FiltersUnitTestMixin
(java.util.Set<java.lang.String> features) |
FiltersUnitTestMixin
() |
Type Params | Return Type | Name and description |
---|---|---|
|
CompositeInterceptor |
getCompositeInterceptor() |
|
CompositeInterceptor |
mockFilters(java.lang.Class filterClass) Mocks a filter class |
|
java.lang.Object |
withFilters(java.util.Map arguments, groovy.lang.Closure callable) Wraps a call to controller in filter execution |
Methods inherited from class | Name |
---|---|
class ControllerUnitTestMixin |
createAndEnhance, getFlash, getGroovyPages, getModel, getParams, getRequest, getResponse, getServletContext, getSession, getStatus, getView, getViews, getWebRequest, mockCommandObject, mockController, testFor |
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#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#getMetaClass(), 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() |
Mocks a filter class
filterClass
- The filter classWraps a call to controller in filter execution
arguments
- Named arguments to specify the 'controller' and 'action' to map tocallable
- The closure code that invokes the controller action