use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.
the class XmlUtils method canonicalize.
public static String canonicalize(String input) throws IOException {
XmlWriter xmlWriter = new XmlWriter();
xmlWriter.setIncludeComments(false);
ContentHandler handler = new PrettyPrintFilter(xmlWriter);
handler = new CanonicalizeFilter(handler);
try {
XmlUtils.parseXml(input, handler);
return xmlWriter.toString();
} catch (SAXException e) {
throw new IOException("ERROR: could not canonicalize [" + input + "]", e);
}
}
use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.
the class OnlyActiveFilterTest method testToWriter.
public void testToWriter(String source, String expected) throws Exception {
StringWriter target = new StringWriter();
XmlWriter xmlWriter = new XmlWriter(target);
OnlyActiveFilter filter = new OnlyActiveFilter(xmlWriter);
XmlUtils.parseXml(source, filter);
String actual = new String(target.toString());
assertEquals(expected, actual);
}
use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.
the class ConfigurationDigesterTest method testNewCanonicalizer.
@Test
public void testNewCanonicalizer() throws Exception {
XmlWriter writer = new XmlWriter();
ConfigurationDigester digester = new ConfigurationDigester();
ContentHandler handler = digester.getConfigurationCanonicalizer(writer, FRANK_CONFIG_XSD, new XmlErrorHandler());
Resource resource = Resource.getResource("/Digester/SimpleConfiguration/Configuration.xml");
XmlUtils.parseXml(resource, handler);
String result = writer.toString();
String expected = TestFileUtils.getTestFile("/Digester/Canonicalized/SimpleConfiguration.xml");
MatchUtils.assertXmlEquals(expected, result);
}
use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.
the class ConfigurationDigesterTest method testFixedValueAttributeResolverWithFrankConfig.
@Test
public void testFixedValueAttributeResolverWithFrankConfig() throws Exception {
URL schemaURL = TestFileUtils.getTestFileURL(FRANK_CONFIG_XSD);
ValidatorHandler validatorHandler = XmlUtils.getValidatorHandler(schemaURL);
XmlWriter writer = new XmlWriter();
validatorHandler.setContentHandler(writer);
validatorHandler.setErrorHandler(new XmlErrorHandler());
Resource resource = Resource.getResource("/Digester/PreParsedConfiguration.xml");
assertNotNull(resource);
XmlUtils.parseXml(resource, validatorHandler);
String expected = TestFileUtils.getTestFile("/Digester/resolvedPreParsedConfiguration.xml");
assertEquals(expected, writer.toString().trim());
}
use of nl.nn.adapterframework.xml.XmlWriter in project iaf by ibissource.
the class ConfigurationDigesterTest method testNewConfigurationPreParser.
// Both OLD and NEW configuration parsers should set the same values for 'loadedConfiguration': properties resolved, secrets hidden
// The new configuration parser returns the configuration with all property not yet resolved
@Test
public void testNewConfigurationPreParser() throws Exception {
ConfigurationDigester digester = new ConfigurationDigester();
Resource resource = Resource.getResource("/Digester/SimpleConfiguration/Configuration.xml");
Properties properties = new Properties();
properties.setProperty("HelloWorld.active", "false");
properties.setProperty("HelloBeautifulWorld.active", "!false");
// new style non-escaped property values
properties.setProperty("digester.property", "[ >\"< ]");
properties.setProperty("secret", "GEHEIM");
properties.setProperty("properties.hide", "secret");
Configuration configuration = new TestConfiguration();
XmlWriter loadedConfigWriter = new XmlWriter();
digester.parseAndResolveEntitiesAndProperties(loadedConfigWriter, configuration, resource, properties);
String result = loadedConfigWriter.toString();
String expected = TestFileUtils.getTestFile("/Digester/Loaded/SimpleConfigurationUnresolved.xml");
MatchUtils.assertXmlEquals(expected, result);
String storedResult = configuration.getLoadedConfiguration();
String storedExpected = TestFileUtils.getTestFile("/Digester/Loaded/SimpleConfigurationResolvedAndHidden.xml");
MatchUtils.assertXmlEquals(storedExpected, storedResult);
loadedConfigWriter = new XmlWriter();
properties.setProperty(STUB4TESTTOOL_CONFIGURATION_KEY, "true");
digester.parseAndResolveEntitiesAndProperties(loadedConfigWriter, configuration, resource, properties);
String stubbedExpected = TestFileUtils.getTestFile("/Digester/Loaded/SimpleConfigurationStubbed.xml");
MatchUtils.assertXmlEquals(stubbedExpected, loadedConfigWriter.toString());
}
Aggregations