ResourceEngine { public ResourceEngine() { this(createVelocityEngine()); } ResourceEngine();  ResourceEngine(VelocityEngine velocityEngine); VelocityContext getVelocityContext(); Resource processResource(Resource resource); Resource processAndAddResource(String name, Resource resource); Resource getResource(String name);  }
@Test public void testResourceEngine() throws Exception { ResourceEngine engine = new ResourceEngine(); engine.processAndAddResource("a", new StringResource("simple", "foo bar baz")); VelocityContext velocityContext = engine.getVelocityContext(); velocityContext.put("v", "direct"); engine.processAndAddResource("b", new StringResource("variables", "process ${a.content} in ${v} mode")); engine.processAndAddResource("c", new StringResource("recursiveVariables", "do ${b.content} and ${a.content}")); Resource resultResource = engine.getResource("b"); assertEquals("process foo bar baz in direct mode", resultResource.getContent()); Resource resultC = engine.getResource("c"); assertEquals("do process foo bar baz in direct mode and foo bar baz", resultC.getContent()); }