use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.
the class JdbcUtilTest method testWarningsToXml.
@Test
public void testWarningsToXml() throws SAXException {
String expected = getExpectedWarningXml();
XmlWriter writer = new XmlWriter();
PrettyPrintFilter ppf = new PrettyPrintFilter(writer);
try (SaxElementBuilder seb = new SaxElementBuilder(ppf)) {
JdbcUtil.warningsToXml(getWarnings(), seb);
MatchUtils.assertXmlEquals(expected, writer.toString());
}
}
use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.
the class XmlUtilsTest method testIdentityTransformWithDefaultEntityResolver.
@Test
public void testIdentityTransformWithDefaultEntityResolver() throws Exception {
// External EntityResolving is still possible with the XMLEntityResolver
Resource resource = Resource.getResource(new TestScopeProvider(), "XmlUtils/EntityResolution/in-file-entity-c-temp.xml");
SAXException thrown = assertThrows(SAXException.class, () -> {
XmlUtils.parseXml(resource, new XmlWriter());
});
String errorMessage = "Cannot get resource for publicId [null] with systemId [file:///c:/temp/test.xml] in scope [URLResource ";
assertTrue("SaxParseException should start with [Cannot get resource ...] but is [" + thrown.getMessage() + "]", thrown.getMessage().startsWith(errorMessage));
}
use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.
the class XmlParserTest method testParseXmlResourceWithExternalEntityInjection.
@Test
@Ignore("requires proper setup on the classpath filesystem. In order for this test to pass properly, the file referenced by the external entity in the input file must exist on the file system. " + "I currently consider it too much of a hassle to automate this setup in a way that works for both Windows and Linux")
public void testParseXmlResourceWithExternalEntityInjection() throws IOException, SAXException, ParserConfigurationException {
Resource input = Resource.getResource("/XmlUtils/EntityResolution/in-file-entity-c-temp.xml");
String expected = TestFileUtils.getTestFile("/XmlUtils/EntityResolution/out-resolved.xml");
XmlWriter writer = new XmlWriter();
XmlUtils.parseXml(input, writer);
MatchUtils.assertXmlEquals(expected, writer.toString());
}
use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.
the class XmlParserTest method testParseXmlNoRelativeEntityInjection.
@Test
public void testParseXmlNoRelativeEntityInjection() throws IOException, SAXException {
URL input = TestFileUtils.getTestFileURL("/XmlUtils/EntityResolution/in-relative-entity.xml");
String expected = TestFileUtils.getTestFile("/XmlUtils/EntityResolution/out-not-resolved.xml");
XmlWriter writer = new XmlWriter();
InputSource source = Message.asInputSource(input);
XmlUtils.parseXml(source, writer);
MatchUtils.assertXmlEquals(expected, writer.toString());
}
use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.
the class XmlParserTest method testParseXmlResourceWithRelativeEntityInjection.
@Test
public void testParseXmlResourceWithRelativeEntityInjection() throws IOException, SAXException, ParserConfigurationException {
Resource input = Resource.getResource("/XmlUtils/EntityResolution/in-relative-entity.xml");
String expected = TestFileUtils.getTestFile("/XmlUtils/EntityResolution/out-resolved.xml");
XmlWriter writer = new XmlWriter();
XmlUtils.parseXml(input, writer);
MatchUtils.assertXmlEquals(expected, writer.toString());
}
Aggregations