Skip to content

Commit ba00568

Browse files
committed
Fix RestfulReverseUrlRenderingTests URL mapping isolation for parallel execution
Add setup/cleanup methods to clear URL mappings artefacts, preventing pollution from parallel tests that register their own URL mappings.
1 parent 9b88d27 commit ba00568

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

grails-gsp/plugin/src/test/groovy/org/grails/web/mapping/RestfulReverseUrlRenderingTests.groovy

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package org.grails.web.mapping
2020

2121
import grails.artefact.Artefact
2222
import grails.testing.web.UrlMappingsUnitTest
23+
import org.grails.core.artefact.UrlMappingsArtefactHandler
2324
import spock.lang.Specification
2425

2526
/**
@@ -29,6 +30,22 @@ import spock.lang.Specification
2930
*/
3031
class RestfulReverseUrlRenderingTests extends Specification implements UrlMappingsUnitTest<RestfulReverseUrlMappings> {
3132

33+
def setup() {
34+
// Clear any existing URL mappings artefacts to prevent pollution from parallel test execution
35+
clearUrlMappingsArtefacts()
36+
}
37+
38+
def cleanup() {
39+
// Clear URL mappings artefacts added by this test to prevent pollution of other tests
40+
clearUrlMappingsArtefacts()
41+
}
42+
43+
private void clearUrlMappingsArtefacts() {
44+
// Access the protected artefactInfo map and remove URL mappings to ensure test isolation
45+
if (grailsApplication instanceof grails.core.DefaultGrailsApplication) {
46+
grailsApplication.@artefactInfo.remove(UrlMappingsArtefactHandler.TYPE)
47+
}
48+
}
3249

3350
def testLinkTagRendering() {
3451
when:

0 commit comments

Comments
 (0)