Search in sources :

Example 6 with XmlWriter

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

the class ConfigurationDigesterTest method simpleXsdWithDefaultAndFixedAttributed.

@Test
public void simpleXsdWithDefaultAndFixedAttributed() throws Exception {
    URL schemaURL = TestFileUtils.getTestFileURL("/Digester/resolveDefaultAttribute.xsd");
    ValidatorHandler validatorHandler = XmlUtils.getValidatorHandler(schemaURL);
    XmlWriter writer = new XmlWriter();
    validatorHandler.setContentHandler(writer);
    validatorHandler.setErrorHandler(new XmlErrorHandler());
    Resource resource = Resource.getResource("/Digester/resolveAttributes.xml");
    XmlUtils.parseXml(resource, validatorHandler);
    assertEquals("<note one=\"1\" two=\"2\"/>", writer.toString().trim());
}
Also used : ValidatorHandler(javax.xml.validation.ValidatorHandler) Resource(nl.nn.adapterframework.core.Resource) URL(java.net.URL) XmlWriter(nl.nn.adapterframework.xml.XmlWriter) Test(org.junit.Test)

Example 7 with XmlWriter

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

the class ConfigurationDigesterTest method stub4testtoolTest.

@Test
public void stub4testtoolTest() throws Exception {
    String baseDirectory = "/ConfigurationUtils/stub4testtool/FullAdapter";
    StringWriter target = new StringWriter();
    XmlWriter xmlWriter = new XmlWriter(target);
    Properties properties = new Properties();
    properties.setProperty(STUB4TESTTOOL_CONFIGURATION_KEY, "true");
    properties.setProperty(STUB4TESTTOOL_VALIDATORS_DISABLED_KEY, Boolean.toString(false));
    String originalConfiguration = TestFileUtils.getTestFile(baseDirectory + "/original.xml");
    ConfigurationDigester digester = new ConfigurationDigester();
    ContentHandler filter = digester.getStub4TesttoolContentHandler(xmlWriter, properties);
    XmlUtils.parseXml(originalConfiguration, filter);
    String actual = new String(target.toString());
    String expectedConfiguration = TestFileUtils.getTestFile(baseDirectory + "/expected.xml");
    MatchUtils.assertXmlEquals(expectedConfiguration, actual);
}
Also used : StringWriter(java.io.StringWriter) Properties(java.util.Properties) ConfigurationDigester(nl.nn.adapterframework.configuration.ConfigurationDigester) XmlWriter(nl.nn.adapterframework.xml.XmlWriter) ContentHandler(org.xml.sax.ContentHandler) Test(org.junit.Test)

Example 8 with XmlWriter

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

the class SoapWrapperTest method replaceDynamicElements.

private String replaceDynamicElements(Message soapBody) throws Exception {
    XmlWriter writer = new XmlWriter();
    RemoveDynamicElements handler = new RemoveDynamicElements(writer);
    XmlUtils.parseXml(soapBody.asInputSource(), handler);
    return writer.toString();
}
Also used : XmlWriter(nl.nn.adapterframework.xml.XmlWriter)

Example 9 with XmlWriter

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

the class XmlWriterTest method testToStream.

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

Example 10 with XmlWriter

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

the class XmlTapTest method testBasic.

@Test
public void testBasic() throws Exception {
    String input = TestFileUtils.getTestFile("/Xslt/AnyXml/in.xml");
    String expected = input;
    XmlWriter xmlWriter = new XmlWriter();
    XmlTap xmlTap = new XmlTap(xmlWriter);
    XmlUtils.parseXml(input, xmlTap);
    assertEquals(expected, xmlWriter.toString());
    assertEquals(expected, xmlTap.getWriter().toString());
}
Also used : XmlWriter(nl.nn.adapterframework.xml.XmlWriter) Test(org.junit.Test)

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