public void testParent() throws Exception { String sText = "${#ifNull(@p:name, \"why\", @p:name)}"; ScriptBlock script = ScriptReader.readBlock(sText); SimpleContext parent = new SimpleContext(); parent.setVariable("p:name", "daniel"); SimpleContext context = new SimpleContext(parent); String sResult = Executer.execute(script, context); assertEquals("daniel", sResult); }
public void testSimpleContext() throws PureException { String sText = "${#ifNull(@p:name, \"why\", @p:name)}"; ScriptBlock script = ScriptReader.readBlock(sText); SimpleContext context = new SimpleContext(); context.setVariable("p:name", null); String sResult = Executer.execute(script, context); assertEquals(sResult, "why"); context.setVariable("p:name", "daniel"); sResult = Executer.execute(script, context); assertEquals(sResult, "daniel"); }
public void testGetFormatterHandler() throws PureException { SimpleContext context = new SimpleContext(); IFormatterHandler handler = context.getFormatterHandler("html"); String sResult = handler.format("hello abc <a>"); assertEquals("hello abc <a>", sResult); }