Skip to content

Commit b5eb7f6

Browse files
author
Joe McCall
committed
Include spec for exception mapping behaviors
1 parent 3d63406 commit b5eb7f6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

grails-test-suite-uber/src/test/groovy/grails/test/mixin/UrlMappingsTestMixinTests.groovy

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ class UrlMappingsTestMixinTests {
166166
assertUrlMapping('/users/timmy', controller: 'user', action: 'update', method: 'put') { name = 'timmy' }
167167
}
168168

169+
@Test
170+
@Issue('https://github.com/grails/grails-core/issues/10226')
171+
void testExceptionUrlMapping() {
172+
mockController(ExceptionTestErrorsController)
173+
mockUrlMappings(ExceptionTestUrlMappings)
174+
175+
assertForwardUrlMapping(500, controller: 'exceptionTestErrors', action: 'handleNullPointer', exception: new NullPointerException())
176+
assertForwardUrlMapping(500, controller: 'exceptionTestErrors', action: 'handleIllegalArgument', exception: new IllegalArgumentException())
177+
assertForwardUrlMapping(500, controller: 'exceptionTestErrors', action: 'handleDefault')
178+
}
179+
169180
@Test
170181
@Issue('https://github.com/grails/grails-core/issues/9065')
171182
void testResourcesUrlMapping() {
@@ -282,3 +293,18 @@ class ResourceTestUrlMappings {
282293
'/person'(resources: 'person')
283294
}
284295
}
296+
297+
@Artefact("Controller")
298+
class ExceptionTestErrorsController {
299+
def handleNullPointer() {}
300+
def handleIllegalArgument() {}
301+
def handleDefault() {}
302+
}
303+
304+
class ExceptionTestUrlMappings {
305+
static mappings = {
306+
'500'(controller: 'exceptionTestErrors', action: 'handleNullPointer', exception: NullPointerException)
307+
'500'(controller: 'exceptionTestErrors', action: 'handleIllegalArgument', exception: IllegalArgumentException)
308+
'500'(controller: 'exceptionTestErrors', action: 'handleDefault')
309+
}
310+
}

0 commit comments

Comments
 (0)