You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a custom TagLib that makes use of the asset-pipeline-grails (version 3.0.6) AssetsTagLib to display images. It calls asset.image() to output an image tag when it renders.
In order to test this, I have a CustomTagLibSpec that implements TagLibUnitTest, and in the setup method I was expecting to be able to do the following to bootstrap and mock the the relevant asset dependencies:
On running the unit test though, I get a failure because grailsApplication is used in the AssetPipelineGrailsPlugin.doWithSpring Closure, and that is not set.
Given that all plugins implement Plugin, and therefore ApplicationContextAware, and GrailsApplicationAware, can the defineBeans(Object plugin) method in GrailsUnitTest be changed to set the grailsApplication and applicationContext from the unit test to avoid having to do it manually please ?
The text was updated successfully, but these errors were encountered:
boardbloke
changed the title
defineBeans(new PluginClass()) does not set grailsApplication /applicationContext?
GrailsUnitTest.defineBeans(new PluginClass()) does not set grailsApplication /applicationContext?
Sep 13, 2018
at whatever.HelloConstollerSpec.basic test(HelloControllerSpec.groovy:17)
Caused by: java.lang.NullPointerException: Cannot get property 'classLoader' on null object
at grails.plugin.json.view.JsonViewGrailsPlugin.doWithSpring_closure1(JsonViewGrailsPlugin.groovy:53)
at groovy.lang.Closure.call(Closure.java:405)
at groovy.lang.Closure.call(Closure.java:399)
at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:759)
at grails.spring.BeanBuilder.beans(BeanBuilder.java:588)
at org.grails.testing.GrailsUnitTest$Trait$Helper.defineBeans(GrailsUnitTest.groovy:97)
at org.grails.testing.GrailsUnitTest$Trait$Helper.defineBeans(GrailsUnitTest.groovy:108)
at com.agorapulse.gru.grails.minions.jsonview.JsonViewRendererMinion.setupJsonViewsPlugin(JsonViewRendererMinion.groovy:80)
at com.agorapulse.gru.grails.minions.jsonview.JsonViewRendererMinion.doBeforeRun(JsonViewRendererMinion.groovy:47)
at com.agorapulse.gru.minions.AbstractMinion.beforeRun(AbstractMinion.java:24)
at com.agorapulse.gru.Squad.beforeRun(Squad.java:125)
at com.agorapulse.gru.Gru.test(Gru.java:135)
at com.agorapulse.gru.Gru.test(Gru.java:105)
... 1 more
I have a custom TagLib that makes use of the asset-pipeline-grails (version 3.0.6) AssetsTagLib to display images. It calls asset.image() to output an image tag when it renders.
In order to test this, I have a CustomTagLibSpec that implements TagLibUnitTest, and in the setup method I was expecting to be able to do the following to bootstrap and mock the the relevant asset dependencies:
On running the unit test though, I get a failure because grailsApplication is used in the AssetPipelineGrailsPlugin.doWithSpring Closure, and that is not set.
If I change my unit test code to
Then my unit test works.
Given that all plugins implement Plugin, and therefore ApplicationContextAware, and GrailsApplicationAware, can the defineBeans(Object plugin) method in GrailsUnitTest be changed to set the grailsApplication and applicationContext from the unit test to avoid having to do it manually please ?
The text was updated successfully, but these errors were encountered: