Search in sources :

Example 1 with ConfigurationDigester

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);
}
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 2 with ConfigurationDigester

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);
}
Also used : Resource(nl.nn.adapterframework.core.Resource) ConfigurationDigester(nl.nn.adapterframework.configuration.ConfigurationDigester) XmlWriter(nl.nn.adapterframework.xml.XmlWriter) ContentHandler(org.xml.sax.ContentHandler) Test(org.junit.Test)

Example 3 with ConfigurationDigester

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());
}
Also used : TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) Configuration(nl.nn.adapterframework.configuration.Configuration) Resource(nl.nn.adapterframework.core.Resource) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) Properties(java.util.Properties) ConfigurationDigester(nl.nn.adapterframework.configuration.ConfigurationDigester) XmlWriter(nl.nn.adapterframework.xml.XmlWriter) Test(org.junit.Test)

Aggregations

ConfigurationDigester (nl.nn.adapterframework.configuration.ConfigurationDigester)3 XmlWriter (nl.nn.adapterframework.xml.XmlWriter)3 Test (org.junit.Test)3 Properties (java.util.Properties)2 Resource (nl.nn.adapterframework.core.Resource)2 ContentHandler (org.xml.sax.ContentHandler)2 StringWriter (java.io.StringWriter)1 Configuration (nl.nn.adapterframework.configuration.Configuration)1 TestConfiguration (nl.nn.adapterframework.testutil.TestConfiguration)1