use of nl.nn.adapterframework.core.PipeLineSessionBase in project iaf by ibissource.
the class SoapValidatorTest method validate12_invalidversion.
@Test(expected = PipeRunException.class)
public void validate12_invalidversion() throws ConfigurationException, IOException, PipeRunException {
SoapValidator xml = getSoapValidator();
xml.setSoapVersion("1.2");
xml.doPipe(getTestXml("/SoapValidator/valid_soap.xml"), new PipeLineSessionBase());
}
use of nl.nn.adapterframework.core.PipeLineSessionBase in project iaf by ibissource.
the class AbstractXmlValidatorTest method validationTest.
protected void validationTest(String namespace, String systemId, String inputfile, boolean addNamespaceToSchema, boolean expectedValid) throws IllegalAccessException, InstantiationException, XmlValidatorException, IOException, PipeRunException, ConfigurationException {
AbstractXmlValidator instance = implementation.newInstance();
instance.setSchemasProvider(new SchemasProviderImpl(namespace, systemId));
instance.setIgnoreUnknownNamespaces(false);
instance.setAddNamespaceToSchema(addNamespaceToSchema);
instance.configure("Setup");
String result = instance.validate(getTestXml(inputfile), new PipeLineSessionBase(), "test", null, null, false);
if (expectedValid) {
Assert.assertEquals("valid XML", result);
} else {
Assert.assertEquals("Invalid XML: does not comply to XSD", result);
}
}
use of nl.nn.adapterframework.core.PipeLineSessionBase 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.core.PipeLineSessionBase 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.core.PipeLineSessionBase in project iaf by ibissource.
the class HttpListenerServlet method invoke.
public void invoke(String message, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
ISecurityHandler securityHandler = new HttpSecurityHandler(request);
IPipeLineSession messageContext = new PipeLineSessionBase();
messageContext.put(IPipeLineSession.securityHandlerKey, securityHandler);
messageContext.put("httpListenerServletRequest", request);
messageContext.put("httpListenerServletResponse", response);
String service = request.getParameter(SERVICE_ID_PARAM);
Enumeration paramnames = request.getParameterNames();
while (paramnames.hasMoreElements()) {
String paramname = (String) paramnames.nextElement();
String paramvalue = request.getParameter(paramname);
if (log.isDebugEnabled()) {
log.debug("HttpListenerServlet setting parameter [" + paramname + "] to [" + paramvalue + "]");
}
messageContext.put(paramname, paramvalue);
}
try {
log.debug("HttpListenerServlet calling service [" + service + "]");
String result = sd.dispatchRequest(service, null, message, messageContext);
response.getWriter().print(result);
} catch (ListenerException e) {
log.warn("HttpListenerServlet caught exception, will rethrow as ServletException", e);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
}
}
Aggregations