I created a simple integration test for a service using a template. Basically, pass some kind of model to the GSP and render it, with the test comparing against a simple string. Sounds easy. All the examples of this usage seem to be consistent, but I get an NPE when I execute it. Many of the examples on the web used no constructor, but since that obviously won't work on the third line of code, I did a new on it, and tried to add a GroovyPagesTemplateEngine as well, in the end.
Here's the service code:
And here's the silly simple template:Code:def listApprovals(userSso) { PageRenderer groovyPageRenderer = new PageRenderer() def results // no need for the code here, just passing a null for now groovyPageRenderer.render template: '/policy/approval', model: [approvals: results] }
I get a null pointer exception as follows: In the PageRenderer class, there is an expectation set:Code:// _approval.gsp Here are your approvals ${approvals}
the variable groovyPageLocator is null, so it's obvious that I'm constructing that PageRenderer class wrongly. or the groovyPageLocator does not get properly injected when the service is initialized.Code:private void renderViewToWriter(Map args, Writer writer) { def source = null if (args.view) { source = groovyPageLocator.findViewByPath(args.view.toString()) } else if (args.template) { source = groovyPageLocator.findTemplateByPath(args.template.toString()) }
I need your thoughts.
Brian


Reply With Quote
