Class FreemarkerTestHelper


  • public class FreemarkerTestHelper
    extends Object
    Helper to write freemarker 'unit' tests
    • Constructor Detail

      • FreemarkerTestHelper

        public FreemarkerTestHelper()
    • Method Detail

      • createTestingConfiguration

        public static freemarker.template.Configuration createTestingConfiguration​(Class<?> clazz,
                                                                                   String template)
                                                                            throws IOException
        Create FreeMarker testing configuration
        Parameters:
        clazz - class to get classloader from for loading templates
        template - example template to be loaded with this configuration (to detect if it's run locally)
        Returns:
        freemarker configuration
        Throws:
        IOException
      • runFreemarkerMacro

        public static String runFreemarkerMacro​(Class<?> clazz,
                                                Map datamodel,
                                                String template,
                                                String macro,
                                                String macroParams)
                                         throws Exception
        Process a template macro using FreeMarker and return the results If template has some 'not macro' code it will be run anyway...
        Parameters:
        clazz - class to get classloader from for loading templates
        datamodel - FreeMarker context
        template - template file name
        macro - macro name in template
        macroParams - call parameters of macro
        Returns:
        result of macro processing
        Throws:
        Exception - if processing went wrong