use of nl.nn.adapterframework.configuration.ConfigurationDigester 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);
}
use of nl.nn.adapterframework.configuration.ConfigurationDigester 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.configuration.ConfigurationDigester 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