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 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); }