Ordering of ServletContextAware and ApplicationContextAware callbacks makes testing FreeMarkerView (and similar classes) impossible [SPR-5398] #10071
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Dave Syer opened SPR-5398 and commented
Ordering of ServletContextAware and ApplicationContextAware callbacks makes testing servlet aware components impossible. I want to test a configuration that contains a FreeMarkerView (which is ServletContextAware), so I added a ServletContextAwareProcessor to my test config, with a MockServletContext. Unfortunately this doesn't work because FreeMarkerView has a base class which is ApplicationContextAware, and it assumes that either the ServletContext is already set or the ApplicationContext is an instance of WebApplicationContext, and neither is the case. But the ServletContext is available, and will eventually be set, so the initialisation is just happening too eagerly. Is it possible to put it in a more orthodox place (like afterPropertiesSet())?
Affects: 2.5.6, 3.0 M1
The text was updated successfully, but these errors were encountered: