@Before public void initRenderer() { TemplateContextFactory contextFactory = mock(TemplateContextFactory.class); when(contextFactory.createContext(anyString(), anyMap())).thenAnswer(new Answer<Map<String, Object>>() { @SuppressWarnings("unchecked") public Map<String, Object> answer(InvocationOnMock invocation) throws Throwable { return (Map<String, Object>) invocation.getArguments()[1]; } }); // ATR-38: To ensure that property overriding works correctly, pass this property // that is also included in our defaults, which is only allowed to have a single value. Map<String, String> initProperties = ImmutableMap.of( "classpath.resource.loader.cache", "true"); renderer = createVelocityRenderer(contextFactory, getClass().getClassLoader(), "test", initProperties); }
private VelocityContext createContext(Map<String, Object> contextParams) { final VelocityContext velocityContext = new VelocityContext(templateContextFactory.createContext(pluginKey, contextParams)); velocityContext.attachEventCartridge( createCartridgeFrom( ImmutableList.of( new DisableHtmlEscapingDirectiveHandler(new TemplateRendererHtmlAnnotationEscaper()) ) ) ); return velocityContext; }
private VelocityContext createContext(Map<String, Object> contextParams) { final VelocityContext velocityContext = new VelocityContext(templateContextFactory.createContext(pluginKey, contextParams)); velocityContext.attachEventCartridge(createCartridgeFrom ( ImmutableList.of(new DisableHtmlEscapingDirectiveHandler(new TemplateRendererHtmlAnnotationEscaper()))) ); return velocityContext; }