use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class XsltPipeErrorTest method importNotFound2.
@Test
public void importNotFound2() throws Exception {
ErrorOutputStream errorOutputStream = new ErrorOutputStream();
System.setErr(new PrintStream(errorOutputStream));
XsltPipe xsltPipe = new XsltPipe();
xsltPipe.registerForward(createPipeSuccessForward());
xsltPipe.setStyleSheetName("/Xslt/importNotFound/root2.xsl");
xsltPipe.setXslt2(true);
String errorMessage = null;
try {
xsltPipe.configure();
} catch (ConfigurationException e) {
errorMessage = e.getMessage();
}
assertEquals(true, errorOutputStream.isEmpty());
assertEquals(0, testAppender.getNumberOfAlerts());
assertEquals(true, errorMessage.contains("Failed to compile stylesheet"));
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class ShowConfigurationStatusTest method initTest.
@BeforeClass
public static void initTest() throws ConfigurationException, TransformerConfigurationException, IOException {
URL adaptersUrl = ClassUtils.getResourceURL(ShowConfigurationStatusTest.class, adapters_xslt);
if (adaptersUrl == null) {
throw new ConfigurationException("cannot find resource [" + adapters_xslt + "]");
}
adaptersTransformer = XmlUtils.createTransformer(adaptersUrl, true);
ibisTester = new IbisTester();
System.setProperty("HelloWorld.job.active", "false");
System.setProperty("junit.active", "true");
System.setProperty("configurations.names", "${instance.name},NotExistingConfig");
ibisTester.initTest();
if (ibisTester.testStartAdapters()) {
ibisContext = ibisTester.getIbisContext();
}
assertEquals(true, ibisContext != null);
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class AbstractXmlValidatorTestBase method validate.
@Override
public String validate(String rootNamespace, String schemaLocation, boolean addNamespaceToSchema, boolean ignoreUnknownNamespaces, String inputfile, String[] expectedFailureReasons) throws ConfigurationException, InstantiationException, IllegalAccessException, XmlValidatorException, PipeRunException, IOException {
AbstractXmlValidator instance = implementation.newInstance();
instance.setSchemasProvider(getSchemasProvider(schemaLocation, addNamespaceToSchema));
instance.setIgnoreUnknownNamespaces(ignoreUnknownNamespaces);
// instance.registerForward("success");
instance.setThrowException(true);
instance.setFullSchemaChecking(true);
String testXml = inputfile != null ? getTestXml(inputfile + ".xml") : null;
PipeLineSessionBase session = new PipeLineSessionBase();
try {
instance.configure("init");
String result = instance.validate(testXml, session, "test", null, null, false);
evaluateResult(result, session, null, expectedFailureReasons);
return result;
} catch (Exception e) {
evaluateResult(null, session, e, expectedFailureReasons);
return "Invalid XML";
}
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class Json2XmlValidatorTest method validate.
@Override
public String validate(String rootNamespace, String schemaLocation, boolean addNamespaceToSchema, boolean ignoreUnknownNamespaces, String inputFile, String[] expectedFailureReasons) throws IOException, ConfigurationException, PipeRunException {
init();
PipeLineSessionBase session = new PipeLineSessionBase();
// instance.setSchemasProvider(getSchemasProvider(schemaLocation, addNamespaceToSchema));
instance.setSchemaLocation(schemaLocation);
instance.setAddNamespaceToSchema(addNamespaceToSchema);
instance.setIgnoreUnknownNamespaces(ignoreUnknownNamespaces);
// instance.registerForward("success");
instance.setThrowException(true);
instance.setFullSchemaChecking(true);
instance.setTargetNamespace(rootNamespace);
instance.registerForward(new PipeForward("failure", null));
instance.registerForward(new PipeForward("parserError", null));
instance.configure(null);
validator.setSchemasProvider(getSchemasProvider(schemaLocation, addNamespaceToSchema));
validator.setIgnoreUnknownNamespaces(ignoreUnknownNamespaces);
validator.configure("setup");
String testXml = inputFile != null ? getTestXml(inputFile + ".xml") : null;
System.out.println("testXml [" + inputFile + ".xml] contents [" + testXml + "]");
String xml2json = (String) jsonPipe.doPipe(testXml, session).getResult();
System.out.println("testXml [" + inputFile + ".xml] to json [" + xml2json + "]");
String testJson = inputFile != null ? getTestXml(inputFile + ".json") : null;
System.out.println("testJson [" + testJson + "]");
try {
PipeRunResult prr = instance.doPipe(testJson, session);
String result = (String) prr.getResult();
System.out.println("result [" + ToStringBuilder.reflectionToString(prr) + "]");
String event;
if (prr.getPipeForward().getName().equals("success")) {
event = "valid XML";
} else {
if (prr.getPipeForward().getName().equals("failure")) {
event = "Invalid XML";
} else {
event = prr.getPipeForward().getName();
}
}
evaluateResult(event, session, null, expectedFailureReasons);
try {
String validationResult = validator.validate(result, session, "check result", null, null, false);
evaluateResult(validationResult, session, null, expectedFailureReasons);
return result;
} catch (Exception e) {
fail("result XML must be valid");
}
return result;
} catch (PipeRunException pre) {
evaluateResult("Invalid XML", session, pre, expectedFailureReasons);
}
return null;
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class Json2XmlValidatorTest method init.
protected void init() throws ConfigurationException {
jsonPipe = new JsonPipe();
jsonPipe.setName("xml2json");
jsonPipe.registerForward(new PipeForward("success", null));
jsonPipe.setDirection("xml2json");
jsonPipe.configure();
try {
validator = implementation.newInstance();
} catch (IllegalAccessException e) {
throw new ConfigurationException(e);
} catch (InstantiationException e) {
throw new ConfigurationException(e);
}
validator.setThrowException(true);
validator.setFullSchemaChecking(true);
instance = new Json2XmlValidator();
instance.registerForward(new PipeForward("success", null));
instance.setSoapNamespace(null);
instance.setFailOnWildcards(false);
}
Aggregations