use of org.apache.camel.converter.jaxp.XmlConverter in project camel by apache.
the class TestHelper method logMessage.
private void logMessage(Exchange exchange, Document inDoc) throws Exception {
XmlConverter converter = new XmlConverter();
String xmlStr = converter.toString(inDoc, exchange);
log.debug(xmlStr);
}
use of org.apache.camel.converter.jaxp.XmlConverter in project camel by apache.
the class CxfUtilsTest method getSubElementString.
private String getSubElementString(String string) throws Exception {
InputStream is = new ByteArrayInputStream(string.getBytes("UTF-8"));
XmlConverter converter = new XmlConverter();
Element element = converter.toDOMElement(converter.toDOMSource(is, null));
Element subElement = (Element) element.getFirstChild();
return CxfUtils.elementToString(subElement);
}
use of org.apache.camel.converter.jaxp.XmlConverter in project camel by apache.
the class XsltBuilderTest method testXsltTemplates.
public void testXsltTemplates() throws Exception {
File file = new File("src/test/resources/org/apache/camel/builder/xml/example.xsl");
Source source = new SAXSource(new InputSource(new FileInputStream(file)));
XmlConverter converter = new XmlConverter();
Templates styleSheet = converter.getTransformerFactory().newTemplates(source);
XsltBuilder builder = XsltBuilder.xslt(styleSheet);
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody("<hello>world!</hello>");
builder.process(exchange);
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>", exchange.getOut().getBody());
}
use of org.apache.camel.converter.jaxp.XmlConverter in project camel by apache.
the class StreamCacheConverterTest method testConvertToStreamCacheStreamSource.
public void testConvertToStreamCacheStreamSource() throws Exception {
context.start();
StreamSource source = new StreamSource(getTestFileStream());
StreamCache cache = StreamCacheConverter.convertToStreamCache(source, exchange);
//assert re-readability of the cached StreamSource
XmlConverter converter = new XmlConverter();
assertNotNull(converter.toString((Source) cache, null));
cache.reset();
assertNotNull(converter.toString((Source) cache, null));
}
use of org.apache.camel.converter.jaxp.XmlConverter 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"));
}
Aggregations