Search in sources :

Example 21 with XmlWriter

use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.

the class DocumentBuilderTest method testXmlDocumentBuilder.

@Test
public void testXmlDocumentBuilder() throws SAXException {
    String expected = expectedXml;
    XmlWriter writer = new XmlWriter();
    try (IDocumentBuilder root = new XmlDocumentBuilder("root", writer)) {
        buildDocument(root);
    }
    MatchUtils.assertXmlEquals(expected, writer.toString());
    assertEquals(expected, writer.toString());
}
Also used : XmlWriter(nl.nn.adapterframework.xml.XmlWriter) Test(org.junit.Test)

Example 22 with XmlWriter

use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.

the class XmlWriterTest method testToWriter.

@Test
public void testToWriter() throws Exception {
    StringWriter target = new StringWriter();
    XmlWriter xmlWriter = new XmlWriter(target);
    sendEvents(xmlWriter);
    String actual = new String(target.toString());
    assertEquals(testString, actual);
}
Also used : StringWriter(java.io.StringWriter) XmlWriter(nl.nn.adapterframework.xml.XmlWriter) Test(org.junit.Test)

Example 23 with XmlWriter

use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.

the class MessageTest method testAsInputSource.

protected void testAsInputSource(Message adapter) throws IOException, SAXException {
    InputSource result = adapter.asInputSource();
    XmlWriter sink = new XmlWriter();
    XmlUtils.parseXml(result, sink);
    String actual = sink.toString();
    MatchUtils.assertXmlEquals(testString, actual);
}
Also used : InputSource(org.xml.sax.InputSource) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) XmlWriter(nl.nn.adapterframework.xml.XmlWriter)

Example 24 with XmlWriter

use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.

the class ToXml method translate.

public String translate(C data) throws SAXException {
    XmlWriter xmlWriter = new XmlWriter();
    setContentHandler(xmlWriter);
    startParse(data);
    return xmlWriter.toString();
}
Also used : XmlWriter(nl.nn.adapterframework.xml.XmlWriter)

Example 25 with XmlWriter

use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.

the class DB2XMLWriter method getXML.

public String getXML(IDbmsSupport dbmsSupport, ResultSet rs, int maxlength, boolean includeFieldDefinition) {
    try {
        XmlWriter xmlWriter = new XmlWriter();
        PrettyPrintFilter ppf = new PrettyPrintFilter(xmlWriter);
        getXML(dbmsSupport, rs, maxlength, includeFieldDefinition, ppf);
        return xmlWriter.toString();
    } catch (SAXException e) {
        log.warn("cannot convert ResultSet to XML", e);
        return "<error>" + XmlUtils.encodeCharsAndReplaceNonValidXmlCharacters(e.getMessage()) + "</error>";
    }
}
Also used : XmlWriter(nl.nn.adapterframework.xml.XmlWriter) PrettyPrintFilter(nl.nn.adapterframework.xml.PrettyPrintFilter) SAXException(org.xml.sax.SAXException)

Aggregations

XmlWriter (nl.nn.adapterframework.xml.XmlWriter)33 Test (org.junit.Test)15 PrettyPrintFilter (nl.nn.adapterframework.xml.PrettyPrintFilter)11 ContentHandler (org.xml.sax.ContentHandler)11 SAXException (org.xml.sax.SAXException)9 Resource (nl.nn.adapterframework.core.Resource)7 IOException (java.io.IOException)6 StringWriter (java.io.StringWriter)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Writer (java.io.Writer)4 XmlTee (nl.nn.adapterframework.stream.xml.XmlTee)4 OutputStream (java.io.OutputStream)3 OutputStreamWriter (java.io.OutputStreamWriter)3 URL (java.net.URL)3 ValidatorHandler (javax.xml.validation.ValidatorHandler)3 ConfigurationDigester (nl.nn.adapterframework.configuration.ConfigurationDigester)3 Message (nl.nn.adapterframework.stream.Message)3 JsonWriter (nl.nn.adapterframework.stream.json.JsonWriter)3 WriterOutputStream (org.apache.commons.io.output.WriterOutputStream)3 Properties (java.util.Properties)2