/** * Test method for {@link * net.hyperadapt.pxweave.interpreter.test.OperationInterpreter#interpreteInsertElement(org.w3c.dom.NodeList, * java.util.ArrayList, int)} . * * @throws XMLWeaverException */ @Test public void testInterpreteInsertElement() throws XMLWeaverException { NodeList joinPoints = xPathEvaluator.evaluateXPath("//books:book/books:title[1]", document); final int lengthOld = joinPoints.item(0).getChildNodes().getLength(); oInterpreter.interpreteInsertElement(joinPoints, testElements3, 0); assertTrue(joinPoints.item(1).getChildNodes().item(0).getNodeName().contentEquals("test1")); assertTrue(joinPoints.item(2).getChildNodes().item(0).getNodeName().contentEquals("test2")); assertTrue( "exactly one Node has to be added", joinPoints.item(0).getChildNodes().getLength() - 1 == lengthOld); joinPoints = xPathEvaluator.evaluateXPath("//books:book[1]", document); oInterpreter.interpreteInsertElement(joinPoints, testElements1, 0); assertTrue( "inserted element must be at position 0", joinPoints.item(0).getChildNodes().item(0).getNodeName().contentEquals("test0")); }
/** * Test method for {@link * net.hyperadapt.pxweave.interpreter.test.OperationInterpreter#interpreteInsertElement(org.w3c.dom.NodeList, * java.util.ArrayList, int)} . * * @throws XMLWeaverException */ @Test(expected = XMLWeaverException.class) public void testInterpreteInsertElementNoElement() throws XMLWeaverException { final NodeList joinPoints = xPathEvaluator.evaluateXPath("//books:book/books:title[1]/text()", document); oInterpreter.interpreteInsertElement(joinPoints, testElements1, -1); }