@SuppressWarnings("deprecation") @Test public void testRegisterAttributeRenderers() { BasicRendererFactory rendererFactory = createMock(BasicRendererFactory.class); ServletApplicationContext applicationContext = createMock(ServletApplicationContext.class); TilesContainer container = createMock(TilesContainer.class); AttributeEvaluatorFactory attributeEvaluatorFactory = createMock(AttributeEvaluatorFactory.class); ServletContext servletContext = createMock(ServletContext.class); rendererFactory.registerRenderer(eq("string"), isA(StringRenderer.class)); rendererFactory.registerRenderer(eq("template"), isA(DispatchRenderer.class)); rendererFactory.registerRenderer(eq("definition"), isA(DefinitionRenderer.class)); rendererFactory.registerRenderer(eq("freemarker"), isA(FreemarkerRenderer.class)); rendererFactory.registerRenderer(eq("velocity"), isA(VelocityRenderer.class)); rendererFactory.registerRenderer(eq("mustache"), isA(MustacheRenderer.class)); expect(applicationContext.getContext()).andReturn(servletContext).anyTimes(); expect(servletContext.getInitParameter(VelocityView.PROPERTIES_KEY)).andReturn(null); expect(servletContext.getInitParameter(VelocityView.TOOLS_KEY)).andReturn(null); expect(servletContext.getAttribute(VelocityView.TOOLS_KEY)).andReturn(null); expect(servletContext.getResourceAsStream("/WEB-INF/velocity.properties")).andReturn( getClass().getResourceAsStream("/velocity.properties")); expect(servletContext.getResourceAsStream("/WEB-INF/VM_global_library.vm")).andReturn( getClass().getResourceAsStream("/VM_global_library.vm")); expect(servletContext.getResourceAsStream("/WEB-INF/tools.xml")).andReturn( getClass().getResourceAsStream("/tools.xml")); expect(servletContext.getResourceAsStream(VelocityView.DEPRECATED_USER_TOOLS_PATH)).andReturn(null); servletContext.log((String) anyObject()); expectLastCall().anyTimes(); expect(servletContext.getRealPath("/")).andReturn(null); replay(rendererFactory, applicationContext, container, attributeEvaluatorFactory, servletContext); factory.registerAttributeRenderers(rendererFactory, applicationContext, container, attributeEvaluatorFactory); verify(rendererFactory, applicationContext, container, attributeEvaluatorFactory, servletContext); }
@Override protected void registerAttributeRenderers( final BasicRendererFactory rendererFactory, final ApplicationContext applicationContext, final TilesContainer container, final AttributeEvaluatorFactory attributeEvaluatorFactory) { super.registerAttributeRenderers(rendererFactory, applicationContext, container, attributeEvaluatorFactory); FreemarkerRenderer freemarkerRenderer = FreemarkerRendererBuilder .createInstance() .setApplicationContext(applicationContext) .setParameter("TemplatePath", "/") .setParameter("NoCache", "true") .setParameter("ContentType", "text/html") .setParameter("template_update_delay", "0") .setParameter("default_encoding", "ISO-8859-1") .setParameter("number_format", "0.##########") .setParameter(SharedVariableLoaderFreemarkerServlet.CUSTOM_SHARED_VARIABLE_FACTORIES_INIT_PARAM, "tiles," + TilesSharedVariableFactory.class.getName()).build(); rendererFactory.registerRenderer(FREEMARKER_RENDERER_NAME, freemarkerRenderer); VelocityRenderer velocityRenderer = VelocityRendererBuilder.createInstance() .setApplicationContext(applicationContext).build(); rendererFactory.registerRenderer(VELOCITY_RENDERER_NAME, velocityRenderer); MustacheRenderer mustacheRenderer = new MustacheRenderer(); mustacheRenderer.setAcceptPattern(Pattern.compile(".+\\.mustache")); rendererFactory.registerRenderer(MUSTACHE_RENDERER_NAME, mustacheRenderer); }
CompleteAutoloadTilesContainerFactory extends BasicTilesContainerFactory { @Override protected void registerAttributeRenderers( final BasicRendererFactory rendererFactory, final ApplicationContext applicationContext, final TilesContainer container, final AttributeEvaluatorFactory attributeEvaluatorFactory) { super.registerAttributeRenderers(rendererFactory, applicationContext, container, attributeEvaluatorFactory); FreemarkerRenderer freemarkerRenderer = FreemarkerRendererBuilder .createInstance() .setApplicationContext(applicationContext) .setParameter("TemplatePath", "/") .setParameter("NoCache", "true") .setParameter("ContentType", "text/html") .setParameter("template_update_delay", "0") .setParameter("default_encoding", "ISO-8859-1") .setParameter("number_format", "0.##########") .setParameter(SharedVariableLoaderFreemarkerServlet.CUSTOM_SHARED_VARIABLE_FACTORIES_INIT_PARAM, "tiles," + TilesSharedVariableFactory.class.getName()).build(); rendererFactory.registerRenderer(FREEMARKER_RENDERER_NAME, freemarkerRenderer); VelocityRenderer velocityRenderer = VelocityRendererBuilder.createInstance() .setApplicationContext(applicationContext).build(); rendererFactory.registerRenderer(VELOCITY_RENDERER_NAME, velocityRenderer); MustacheRenderer mustacheRenderer = new MustacheRenderer(); mustacheRenderer.setAcceptPattern(Pattern.compile(".+\\.mustache")); rendererFactory.registerRenderer(MUSTACHE_RENDERER_NAME, mustacheRenderer); } }
CompleteAutoloadTilesContainerFactory extends BasicTilesContainerFactory { @Override protected void registerAttributeRenderers( final BasicRendererFactory rendererFactory, final ApplicationContext applicationContext, final TilesContainer container, final AttributeEvaluatorFactory attributeEvaluatorFactory) { super.registerAttributeRenderers(rendererFactory, applicationContext, container, attributeEvaluatorFactory); FreemarkerRenderer freemarkerRenderer = FreemarkerRendererBuilder .createInstance() .setApplicationContext(applicationContext) .setParameter("TemplatePath", "/") .setParameter("NoCache", "true") .setParameter("ContentType", "text/html") .setParameter("template_update_delay", "0") .setParameter("default_encoding", "ISO-8859-1") .setParameter("number_format", "0.##########") .setParameter(SharedVariableLoaderFreemarkerServlet.CUSTOM_SHARED_VARIABLE_FACTORIES_INIT_PARAM, "tiles," + TilesSharedVariableFactory.class.getName()).build(); rendererFactory.registerRenderer(FREEMARKER_RENDERER_NAME, freemarkerRenderer); VelocityRenderer velocityRenderer = VelocityRendererBuilder.createInstance() .setApplicationContext(applicationContext).build(); rendererFactory.registerRenderer(VELOCITY_RENDERER_NAME, velocityRenderer); MustacheRenderer mustacheRenderer = new MustacheRenderer(); mustacheRenderer.setAcceptPattern(Pattern.compile(".+\\.mustache")); rendererFactory.registerRenderer(MUSTACHE_RENDERER_NAME, mustacheRenderer); }  }
CompleteAutoloadTilesContainerFactory extends BasicTilesContainerFactory { @Override protected void registerAttributeRenderers( final BasicRendererFactory rendererFactory, final ApplicationContext applicationContext, final TilesContainer container, final AttributeEvaluatorFactory attributeEvaluatorFactory) { super.registerAttributeRenderers(rendererFactory, applicationContext, container, attributeEvaluatorFactory); FreemarkerRenderer freemarkerRenderer = FreemarkerRendererBuilder .createInstance() .setApplicationContext(applicationContext) .setParameter("TemplatePath", "/") .setParameter("NoCache", "true") .setParameter("ContentType", "text/html") .setParameter("template_update_delay", "0") .setParameter("default_encoding", "ISO-8859-1") .setParameter("number_format", "0.##########") .setParameter(SharedVariableLoaderFreemarkerServlet.CUSTOM_SHARED_VARIABLE_FACTORIES_INIT_PARAM, "tiles," + TilesSharedVariableFactory.class.getName()).build(); rendererFactory.registerRenderer(FREEMARKER_RENDERER_NAME, freemarkerRenderer); VelocityRenderer velocityRenderer = VelocityRendererBuilder.createInstance() .setApplicationContext(applicationContext).build(); rendererFactory.registerRenderer(VELOCITY_RENDERER_NAME, velocityRenderer); MustacheRenderer mustacheRenderer = new MustacheRenderer(); mustacheRenderer.setAcceptPattern(Pattern.compile(".+\\.mustache")); rendererFactory.registerRenderer(MUSTACHE_RENDERER_NAME, mustacheRenderer); }  @Override TilesContainer createDecoratedContainer(TilesContainer originalContainer,
            ApplicationContext applicationContext); }
CompleteAutoloadTilesContainerFactory extends BasicTilesContainerFactory { @Override protected void registerAttributeRenderers( final BasicRendererFactory rendererFactory, final ApplicationContext applicationContext, final TilesContainer container, final AttributeEvaluatorFactory attributeEvaluatorFactory) { super.registerAttributeRenderers(rendererFactory, applicationContext, container, attributeEvaluatorFactory); FreemarkerRenderer freemarkerRenderer = FreemarkerRendererBuilder .createInstance() .setApplicationContext(applicationContext) .setParameter("TemplatePath", "/") .setParameter("NoCache", "true") .setParameter("ContentType", "text/html") .setParameter("template_update_delay", "0") .setParameter("default_encoding", "ISO-8859-1") .setParameter("number_format", "0.##########") .setParameter(SharedVariableLoaderFreemarkerServlet.CUSTOM_SHARED_VARIABLE_FACTORIES_INIT_PARAM, "tiles," + TilesSharedVariableFactory.class.getName()).build(); rendererFactory.registerRenderer(FREEMARKER_RENDERER_NAME, freemarkerRenderer); VelocityRenderer velocityRenderer = VelocityRendererBuilder.createInstance() .setApplicationContext(applicationContext).build(); rendererFactory.registerRenderer(VELOCITY_RENDERER_NAME, velocityRenderer); MustacheRenderer mustacheRenderer = new MustacheRenderer(); mustacheRenderer.setAcceptPattern(Pattern.compile(".+\\.mustache")); rendererFactory.registerRenderer(MUSTACHE_RENDERER_NAME, mustacheRenderer); }  @Override TilesContainer createDecoratedContainer(TilesContainer originalContainer,
            ApplicationContext applicationContext);  }