@Test public void getVelocityContext() throws ComponentLookupException { VelocityContext context = this.mocker.getComponentUnderTest().getVelocityContext(); assertNull(context.get("doc")); assertNull(context.get("sdoc")); DocumentReference docReference = new DocumentReference("wiki", "space", "doc"); DocumentReference sdocReference = new DocumentReference("wiki", "space", "sdoc"); this.oldcore.getXWikiContext().setDoc(new XWikiDocument(docReference)); this.oldcore.getXWikiContext().put("sdoc", new XWikiDocument(sdocReference)); context = this.mocker.getComponentUnderTest().getVelocityContext(); Document doc = (Document) context.get("doc"); assertNotNull(doc); Document sdoc = (Document) context.get("sdoc"); assertNotNull(sdoc); context = this.mocker.getComponentUnderTest().getVelocityContext(); assertSame(doc, context.get("doc")); assertSame(sdoc, context.get("sdoc")); docReference = new DocumentReference("wiki", "space", "doc2"); sdocReference = new DocumentReference("wiki", "space", "sdoc2"); this.oldcore.getXWikiContext().setDoc(new XWikiDocument(docReference)); this.oldcore.getXWikiContext().put("sdoc", new XWikiDocument(sdocReference)); context = this.mocker.getComponentUnderTest().getVelocityContext(); assertNotNull(context.get("doc")); assertNotSame(doc, context.get("doc")); assertNotNull(context.get("sdoc")); assertNotSame(sdoc, context.get("sdoc")); }
@Override public VelocityContext getVelocityContext() { ScriptVelocityContext velocityContext; VelocityContext currentVelocityContext = getCurrentVelocityContext(); if (currentVelocityContext instanceof ScriptVelocityContext) { velocityContext = (ScriptVelocityContext) currentVelocityContext; } else { velocityContext = new ScriptVelocityContext(currentVelocityContext, this.reservedBindings); this.execution.getContext().setProperty(VelocityExecutionContextInitializer.VELOCITY_CONTEXT_ID, velocityContext); } ScriptContext scriptContext = this.scriptContextManager.getScriptContext(); velocityContext.setScriptContext(scriptContext); XWikiContext xcontext = this.xcontextProvider.get(); velocityContext.put("context", new DeprecatedContext(xcontext)); return velocityContext; }
DefaultVelocityManager implements VelocityManager, Initializable { @Override public VelocityContext getVelocityContext() { ScriptVelocityContext velocityContext; VelocityContext currentVelocityContext = getCurrentVelocityContext(); if (currentVelocityContext instanceof ScriptVelocityContext) { velocityContext = (ScriptVelocityContext) currentVelocityContext; } else { velocityContext = new ScriptVelocityContext(currentVelocityContext, this.reservedBindings); this.execution.getContext().setProperty(VelocityExecutionContextInitializer.VELOCITY_CONTEXT_ID, velocityContext); } ScriptContext scriptContext = this.scriptContextManager.getScriptContext(); velocityContext.setScriptContext(scriptContext); XWikiContext xcontext = this.xcontextProvider.get(); velocityContext.put("context", new DeprecatedContext(xcontext)); return velocityContext; } }
DefaultVelocityManager implements VelocityManager, Initializable { @Override public VelocityContext getVelocityContext() { ScriptVelocityContext velocityContext; VelocityContext currentVelocityContext = getCurrentVelocityContext(); if (currentVelocityContext instanceof ScriptVelocityContext) { velocityContext = (ScriptVelocityContext) currentVelocityContext; } else { velocityContext = new ScriptVelocityContext(currentVelocityContext, this.reservedBindings); this.execution.getContext().setProperty(VelocityExecutionContextInitializer.VELOCITY_CONTEXT_ID, velocityContext); } ScriptContext scriptContext = this.scriptContextManager.getScriptContext(); velocityContext.setScriptContext(scriptContext); XWikiContext xcontext = this.xcontextProvider.get(); velocityContext.put("context", new DeprecatedContext(xcontext)); return velocityContext; }  }
DefaultVelocityManager implements VelocityManager, Initializable { @Override public VelocityContext getVelocityContext() { ScriptVelocityContext velocityContext; VelocityContext currentVelocityContext = getCurrentVelocityContext(); if (currentVelocityContext instanceof ScriptVelocityContext) { velocityContext = (ScriptVelocityContext) currentVelocityContext; } else { velocityContext = new ScriptVelocityContext(currentVelocityContext, this.reservedBindings); this.execution.getContext().setProperty(VelocityExecutionContextInitializer.VELOCITY_CONTEXT_ID, velocityContext); } ScriptContext scriptContext = this.scriptContextManager.getScriptContext(); velocityContext.setScriptContext(scriptContext); XWikiContext xcontext = this.xcontextProvider.get(); velocityContext.put("context", new DeprecatedContext(xcontext)); return velocityContext; }  @Override void initialize(); @Override VelocityContext getVelocityContext(); @Override VelocityContext getCurrentVelocityContext(); @Override VelocityEngine getVelocityEngine(); @Override boolean evaluate(Writer out, String templateName, Reader source); }
DefaultVelocityManager implements VelocityManager, Initializable { @Override public VelocityContext getVelocityContext() { ScriptVelocityContext velocityContext; VelocityContext currentVelocityContext = getCurrentVelocityContext(); if (currentVelocityContext instanceof ScriptVelocityContext) { velocityContext = (ScriptVelocityContext) currentVelocityContext; } else { velocityContext = new ScriptVelocityContext(currentVelocityContext, this.reservedBindings); this.execution.getContext().setProperty(VelocityExecutionContextInitializer.VELOCITY_CONTEXT_ID, velocityContext); } ScriptContext scriptContext = this.scriptContextManager.getScriptContext(); velocityContext.setScriptContext(scriptContext); XWikiContext xcontext = this.xcontextProvider.get(); velocityContext.put("context", new DeprecatedContext(xcontext)); return velocityContext; }  @Override void initialize(); @Override VelocityContext getVelocityContext(); @Override VelocityContext getCurrentVelocityContext(); @Override VelocityEngine getVelocityEngine(); @Override boolean evaluate(Writer out, String templateName, Reader source);  }