Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix for GRAILS-9718 "NullPointerException in Grails unit tests becaus…

…e of null Params and Session"
  • Loading branch information...
commit c94c133414c2e39170cea4aa34cb7ec2b0639b5a 1 parent efe9112
@graemerocher graemerocher authored
View
3  grails-plugin-testing/src/main/groovy/grails/test/mixin/web/GroovyPageUnitTestMixin.groovy
@@ -23,6 +23,7 @@ import org.codehaus.groovy.grails.commons.GrailsTagLibClass
import org.codehaus.groovy.grails.commons.TagLibArtefactHandler
import org.codehaus.groovy.grails.commons.metaclass.MetaClassEnhancer
import org.codehaus.groovy.grails.plugins.web.api.TagLibraryApi
+import org.codehaus.groovy.grails.web.pages.GroovyPageRequestBinding
import org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine
import org.codehaus.groovy.grails.web.pages.TagLibraryLookup
import org.codehaus.groovy.grails.web.plugins.support.WebMetaUtils;
@@ -60,7 +61,7 @@ class GroovyPageUnitTestMixin extends ControllerUnitTestMixin {
@Before
void bindGrailsWebRequest() {
super.bindGrailsWebRequest()
- pageScope = new GroovyPageBinding()
+ pageScope = new GroovyPageBinding(new GroovyPageRequestBinding(webRequest))
request.setAttribute(GrailsApplicationAttributes.PAGE_SCOPE, pageScope)
}
View
9 grails-test-suite-uber/src/test/groovy/grails/test/mixin/ControllerAndGroovyPageMixinTests.groovy
@@ -10,9 +10,16 @@ import org.junit.Test
@TestFor(MyController)
class ControllerAndGroovyPageMixinTests {
- // verifies the above 2 mixins can operator together without error
+ // GRAILS-9718
@Test
void testController() {
controller != null
+
+ views['/foo/_bar.gsp'] = 'Id: ${params.id}'
+
+ params.id = 10
+ def content = render(template:"/foo/bar")
+
+ assert content == 'Id: 10'
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.