use of nl.nn.adapterframework.core.Resource 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.core.Resource 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());
}
use of nl.nn.adapterframework.core.Resource in project iaf by ibissource.
the class XsltProviderListener method init.
public void init() throws ListenerException {
try {
Resource stylesheet;
if (fromClasspath) {
stylesheet = Resource.getResource(filename);
} else {
File file = new File(filename);
stylesheet = Resource.getResource(null, file.toURI().toURL().toExternalForm(), "file");
}
transformerPool = TransformerPool.getInstance(stylesheet, getXsltVersion());
} catch (Exception e) {
throw new ListenerException("Exception creating transformer pool for file '" + filename + "': " + e.getMessage(), e);
}
}
use of nl.nn.adapterframework.core.Resource in project iaf by ibissource.
the class EsbJmsTransactionalStorage method configure.
@Override
public void configure() throws ConfigurationException {
super.configure();
String exceptionLogString = "/xml/xsl/esb/exceptionLog.xsl";
String auditLogString = "/xml/xsl/esb/auditLog.xsl";
try {
Resource exceptionLogResource = Resource.getResource(this, exceptionLogString);
if (exceptionLogResource == null) {
throw new ConfigurationException(getLogPrefix() + "cannot find stylesheet [" + exceptionLogString + "]");
}
exceptionLogTp = TransformerPool.getInstance(exceptionLogResource, 2);
} catch (IOException e) {
throw new ConfigurationException(getLogPrefix() + "cannot retrieve [" + exceptionLogString + "]", e);
} catch (TransformerConfigurationException te) {
throw new ConfigurationException(getLogPrefix() + "got error creating transformer from file [" + exceptionLogString + "]", te);
}
try {
Resource auditLogResource = Resource.getResource(this, auditLogString);
if (auditLogResource == null) {
throw new ConfigurationException(getLogPrefix() + "cannot find stylesheet [" + auditLogString + "]");
}
auditLogTp = TransformerPool.getInstance(auditLogResource, 2);
} catch (IOException e) {
throw new ConfigurationException(getLogPrefix() + "cannot retrieve [" + auditLogString + "]", e);
} catch (TransformerConfigurationException te) {
throw new ConfigurationException(getLogPrefix() + "got error creating transformer from file [" + auditLogString + "]", te);
}
}
use of nl.nn.adapterframework.core.Resource in project iaf by ibissource.
the class WsdlGeneratorPipe method createPipeLineFromXsdFile.
private PipeLine createPipeLineFromXsdFile(File xsdFile) throws ConfigurationException {
PipeLine pipeLine = new PipeLine();
EsbSoapValidator inputValidator;
inputValidator = createValidator(xsdFile, null, null, 1, 1, pipeLine);
pipeLine.setInputValidator(inputValidator);
String countRoot = null;
try {
String countRootXPath = "count(*/*[local-name()='element'])";
TransformerPool tp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(countRootXPath, OutputType.TEXT));
Resource xsdResource = Resource.getResource(xsdFile.getPath());
countRoot = tp.transform(xsdResource.asSource());
if (StringUtils.isNotEmpty(countRoot)) {
log.debug("counted [" + countRoot + "] root elements in xsd file [" + xsdFile.getName() + "]");
int cr = Integer.parseInt(countRoot);
if (cr > 1) {
EsbSoapValidator outputValidator;
outputValidator = createValidator(xsdFile, null, null, 2, 1, pipeLine);
pipeLine.setOutputValidator(outputValidator);
}
}
} catch (Exception e) {
throw new ConfigurationException(e);
}
return pipeLine;
}
Aggregations