Working in a Unit Test, not in Application

Peter Harrison <[email protected]> Tue, 01 Sep 2015 14:28:27 +1200
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
I've written a wrapper around Freemarker for use in my application. My 
unit test runs the following template:

<#assign hello="Goodbye cruel world">
${hello}

And you get "Goodbye cruel world" as you would expect.

But in my application, which runs inside Tomcat, the same template 
results in nothing. Nada. Exactly the same code, two different outcomes. 
Obviously something environmental, but I have no idea what.

public class TemplatePlugin implements Plugin {

     @Autowired
     private ResourceController resourceController;

     @Override
     public Map<String,Object> process( Action action, 
Map<String,Object> context ) throws Exception{
         String resource = 
getResourceController().getResource(action.getResource());

         Configuration configuration = new Configuration();
         configuration.setDefaultEncoding("UTF-8");

         Template template = new Template(action.getResource(), new 
StringReader(resource), configuration);
         Writer output = new StringWriter();
         template.process(context, output);
         String result = output.toString();
         context.put(action.getResponse(), result);
         return context;
     }

}

------------------------------------------------------------------------------