use of org.w3c.dom.NodeList in project camel by apache.
the class XPathTest method testXPathNodeSetResult.
public void testXPathNodeSetResult() throws Exception {
Object result = xpath("/foo").nodeSetResult().evaluate(createExchange("<foo>bar</foo>"));
NodeList node = assertIsInstanceOf(NodeList.class, result);
assertNotNull(node);
String s = context.getTypeConverter().convertTo(String.class, node);
assertEquals("<foo>bar</foo>", s);
}
use of org.w3c.dom.NodeList in project camel by apache.
the class DumpModelAsXmlSplitBodyRouteTest method testDumpModelAsXml.
public void testDumpModelAsXml() throws Exception {
String xml = ModelHelper.dumpModelAsXml(context, context.getRouteDefinition("myRoute"));
assertNotNull(xml);
log.info(xml);
Document doc = new XmlConverter().toDOMDocument(xml);
NodeList nodes = doc.getElementsByTagName("simple");
assertEquals(1, nodes.getLength());
Element node = (Element) nodes.item(0);
assertNotNull("Node <simple> expected to be instanceof Element", node);
assertEquals("body", node.getTextContent());
nodes = doc.getElementsByTagName("split");
assertEquals(1, nodes.getLength());
nodes = doc.getElementsByTagName("to");
assertEquals(1, nodes.getLength());
node = (Element) nodes.item(0);
assertNotNull("Node <to> expected to be instanceof Element", node);
assertEquals("mock:sub", node.getAttribute("uri"));
assertEquals("myMock", node.getAttribute("id"));
assertEquals("true", node.getAttribute("customId"));
}
use of org.w3c.dom.NodeList in project camel by apache.
the class DumpModelAsXmlTransformRouteConstantTest method testDumpModelAsXml.
public void testDumpModelAsXml() throws Exception {
String xml = ModelHelper.dumpModelAsXml(context, context.getRouteDefinition("myRoute"));
assertNotNull(xml);
log.info(xml);
Document doc = new XmlConverter().toDOMDocument(xml);
NodeList nodes = doc.getElementsByTagName("constant");
assertEquals(1, nodes.getLength());
Element node = (Element) nodes.item(0);
assertNotNull("Node <simple> expected to be instanceof Element", node);
assertEquals("Hello World", node.getTextContent());
nodes = doc.getElementsByTagName("to");
assertEquals(1, nodes.getLength());
node = (Element) nodes.item(0);
assertNotNull("Node <to> expected to be instanceof Element", node);
assertEquals("mock:result", node.getAttribute("uri"));
assertEquals("myMock", node.getAttribute("id"));
assertEquals("true", node.getAttribute("customId"));
}
use of org.w3c.dom.NodeList in project camel by apache.
the class DumpModelAsXmlTransformRouteLanguageTest method testDumpModelAsXml.
public void testDumpModelAsXml() throws Exception {
String xml = ModelHelper.dumpModelAsXml(context, context.getRouteDefinition("myRoute"));
assertNotNull(xml);
log.info(xml);
Document doc = new XmlConverter().toDOMDocument(xml);
NodeList nodes = doc.getElementsByTagName("language");
assertEquals(1, nodes.getLength());
Element node = (Element) nodes.item(0);
assertNotNull("Node <simple> expected to be instanceof Element", node);
assertEquals("constant", node.getAttribute("language"));
assertEquals("Hello World", node.getTextContent());
nodes = doc.getElementsByTagName("to");
assertEquals(1, nodes.getLength());
node = (Element) nodes.item(0);
assertNotNull("Node <to> expected to be instanceof Element", node);
assertEquals("mock:result", node.getAttribute("uri"));
assertEquals("myMock", node.getAttribute("id"));
assertEquals("true", node.getAttribute("customId"));
}
use of org.w3c.dom.NodeList in project camel by apache.
the class DumpModelAsXmlTransformRouteTest method testDumpModelAsXml.
public void testDumpModelAsXml() throws Exception {
String xml = ModelHelper.dumpModelAsXml(context, context.getRouteDefinition("myRoute"));
assertNotNull(xml);
log.info(xml);
Document doc = new XmlConverter().toDOMDocument(xml);
NodeList nodes = doc.getElementsByTagName("simple");
assertEquals(1, nodes.getLength());
Element node = (Element) nodes.item(0);
assertNotNull("Node <simple> expected to be instanceof Element", node);
assertEquals("Hello ${body}", node.getTextContent());
nodes = doc.getElementsByTagName("to");
assertEquals(1, nodes.getLength());
node = (Element) nodes.item(0);
assertNotNull("Node <to> expected to be instanceof Element", node);
assertEquals("mock:result", node.getAttribute("uri"));
assertEquals("myMock", node.getAttribute("id"));
assertEquals("true", node.getAttribute("customId"));
}
Aggregations