@Test void evaluateMacroParameters() throws Exception { this.engine.initialize(new Properties()); assertEvaluate("$caller", "#macro (testMacro $called)$called#end#testMacro($caller)"); assertEvaluate("$caller", "#macro (testMacro $called)#set($called = $NULL)$called#set($called = 'value')#end#testMacro($caller)"); assertEvaluate("$caller", "#macro (testMacro $called)#set($called = $NULL)$called#set($called = 'value')#end#set($caller = 'value')#testMacro($caller)"); assertEvaluate("$caller$caller2$caller", "#macro(macro1 $called)$called#macro2($caller2)$called#end#macro(macro2 $called)$called#end#macro1($caller)"); Context context = new XWikiVelocityContext(); context.put("test", new TestClass(context)); context.put("other", new TestClass(context, "othername")); assertEvaluate("namename", "#macro (testMacro $test $name)$name#end$test.name#testMacro($other, $test.name)", context); }
@Override public void initialize(Properties overridingProperties) throws XWikiVelocityException { RuntimeInstance runtime = new RuntimeInstance(); runtime.setApplicationAttribute(ComponentManager.class.getName(), this.componentManager); initializeProperties(runtime, this.velocityConfiguration.getProperties(), overridingProperties); runtime.loadDirective(TryCatchDirective.class.getName()); try { runtime.init(); } catch (Exception e) { throw new XWikiVelocityException("Cannot start the Velocity engine", e); } this.runtimeInstance = runtime; this.globalEntry = new TemplateEntry(""); }
DefaultVelocityEngine implements VelocityEngine { @Override public void initialize(Properties overridingProperties) throws XWikiVelocityException { RuntimeInstance runtime = new RuntimeInstance(); runtime.setApplicationAttribute(ComponentManager.class.getName(), this.componentManager); initializeProperties(runtime, this.velocityConfiguration.getProperties(), overridingProperties); runtime.loadDirective(TryCatchDirective.class.getName()); try { runtime.init(); } catch (Exception e) { throw new XWikiVelocityException("Cannot start the Velocity engine", e); } this.runtimeInstance = runtime; this.globalEntry = new TemplateEntry(""); } }
DefaultVelocityEngine implements VelocityEngine { @Override public void initialize(Properties overridingProperties) throws XWikiVelocityException { RuntimeInstance runtime = new RuntimeInstance(); runtime.setApplicationAttribute(ComponentManager.class.getName(), this.componentManager); initializeProperties(runtime, this.velocityConfiguration.getProperties(), overridingProperties); runtime.loadDirective(TryCatchDirective.class.getName()); try { runtime.init(); } catch (Exception e) { throw new XWikiVelocityException("Cannot start the Velocity engine", e); } this.runtimeInstance = runtime; this.globalEntry = new TemplateEntry(""); }  }
DefaultVelocityEngine implements VelocityEngine { @Override public void initialize(Properties overridingProperties) throws XWikiVelocityException { RuntimeInstance runtime = new RuntimeInstance(); runtime.setApplicationAttribute(ComponentManager.class.getName(), this.componentManager); initializeProperties(runtime, this.velocityConfiguration.getProperties(), overridingProperties); runtime.loadDirective(TryCatchDirective.class.getName()); try { runtime.init(); } catch (Exception e) { throw new XWikiVelocityException("Cannot start the Velocity engine", e); } this.runtimeInstance = runtime; this.globalEntry = new TemplateEntry(""); }  @Override void initialize(Properties overridingProperties); @Override boolean evaluate(Context context, Writer out, String templateName, String source); @Override boolean evaluate(Context context, Writer out, String namespace, Reader source); @Override @Deprecated void clearMacroNamespace(String namespace); @Override void startedUsingMacroNamespace(String namespace); @Override void stoppedUsingMacroNamespace(String namespace); }
DefaultVelocityEngine implements VelocityEngine { @Override public void initialize(Properties overridingProperties) throws XWikiVelocityException { RuntimeInstance runtime = new RuntimeInstance(); runtime.setApplicationAttribute(ComponentManager.class.getName(), this.componentManager); initializeProperties(runtime, this.velocityConfiguration.getProperties(), overridingProperties); runtime.loadDirective(TryCatchDirective.class.getName()); try { runtime.init(); } catch (Exception e) { throw new XWikiVelocityException("Cannot start the Velocity engine", e); } this.runtimeInstance = runtime; this.globalEntry = new TemplateEntry(""); }  @Override void initialize(Properties overridingProperties); @Override boolean evaluate(Context context, Writer out, String templateName, String source); @Override boolean evaluate(Context context, Writer out, String namespace, Reader source); @Override @Deprecated void clearMacroNamespace(String namespace); @Override void startedUsingMacroNamespace(String namespace); @Override void stoppedUsingMacroNamespace(String namespace);  }