s.append("var items = dom2js(_context.readVariable('items'));\n");
s.append("items.TestPart.items.item += item.TestPart.item;\n");
s.append("items.TestPart.items.item.(@hyped=='true').price *= 2;");
s.append("_context.writeVariable('items', js2dom(items));\n");
MockExtensionContext c = new MockExtensionContext();
c.getVariables().put("item", DOMUtils.stringToDOM("<message><TestPart><item hyped=\"true\"><name>BPEL consulting</name><price>3000</price></item></TestPart></message>"));
c.getVariables().put("items", DOMUtils.stringToDOM("<message><TestPart><items><item><name>WSDL consulting</name><price>2500</price></item></items></TestPart></message>"));
JSExtensionOperation jso = new JSExtensionOperation();
Element e = DOMUtils.stringToDOM("<js:script xmlns:js=\"js\"><![CDATA[" + s + "]]></js:script>");
jso.run(c, e);
String res = DOMUtils.domToString(c.getVariables().get("items"));
Assert.assertTrue(c.completed);
Assert.assertFalse(c.faulted);
Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<message><TestPart><items><item><name>WSDL consulting</name><price>2500</price></item><item hyped=\"true\"><name>BPEL consulting</name><price>6000</price></item></items></TestPart></message>", res);
}