use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class XmlValidatorTest method testWrongRootElement.
@Test
public void testWrongRootElement() throws Exception {
String schema = SCHEMA_LOCATION_BASIC_A_OK;
String inputFile = INPUT_FILE_BASIC_A_OK;
XmlValidator validator = new XmlValidator();
validator.registerForward(createSuccessForward());
validator.registerForward(createFailureForward());
validator.setFullSchemaChecking(true);
validator.setRoot("anotherElement");
validator.setReasonSessionKey("reason");
validator.setSchemaLocation(schema);
validator.configure();
validator.start();
String testXml = inputFile != null ? getTestXml(inputFile + ".xml") : null;
PipeLineSession session = new PipeLineSession();
PipeRunResult result = validator.doPipe(new Message(testXml), session);
PipeForward forward = result.getPipeForward();
assertEquals("failure", forward.getName());
assertThat((String) session.get("reason"), containsString("Illegal element 'A'. Element(s) 'anotherElement' expected."));
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class XmlValidatorTest method testRuntimeRootElement.
@Test
public void testRuntimeRootElement() throws Exception {
String schema = SCHEMA_LOCATION_BASIC_A_OK;
String root = "A";
String inputFile = INPUT_FILE_BASIC_A_OK;
XmlValidator validator = new XmlValidator();
validator.registerForward(createSuccessForward());
validator.registerForward(createFailureForward());
validator.setFullSchemaChecking(true);
// if multiple root elements are specified, in a comma separated list, the validation succeeds if one of these root elements is found
validator.setRoot("oneElement,anotherElement");
validator.setSchemaLocation(schema);
validator.configure();
validator.start();
String testXml = inputFile != null ? getTestXml(inputFile + ".xml") : null;
PipeLineSession session = new PipeLineSession();
PipeRunResult result = validator.validate(new Message(testXml), session, root);
PipeForward forward = result.getPipeForward();
assertEquals("success", forward.getName());
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class InputOutputSenderWrapperProcessorTest method getSenderWrapper.
public SenderWrapperBase getSenderWrapper() {
SenderSeries senderSeries = new SenderSeries();
senderSeries.registerSender(new SenderBase() {
@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
try {
return new Message("Sender 1: [" + message.asString() + "]");
} catch (IOException e) {
throw new SenderException(e);
}
}
});
senderSeries.registerSender(new SenderBase() {
@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
try {
secondSenderOutput = "Sender 2: [" + message.asString() + "]";
return new Message(secondSenderOutput);
} catch (IOException e) {
throw new SenderException(e);
}
}
});
return senderSeries;
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class SoapWrapperTest method getBodyXmlAndStoreSoapNamespace.
@Test
public void getBodyXmlAndStoreSoapNamespace() throws ConfigurationException {
SoapWrapper soapWrapper = SoapWrapper.getInstance();
String soapMessage = xmlMessage;
String expectedSoapBody = xmlMessage;
String soapBody = null;
PipeLineSession session = new PipeLineSession();
String sessionKey = "SoapVersion";
try {
soapBody = soapWrapper.getBody(new Message(soapMessage), true, session, sessionKey).asString();
} catch (Exception e) {
soapBody = e.getMessage();
}
assertEquals(expectedSoapBody, soapBody);
String soapVersion = (String) session.get(sessionKey);
assertEquals(SoapVersion.NONE.namespace, soapVersion);
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class SoapWrapperTest method getBody11AndStoreSoapNamespace.
@Test
public void getBody11AndStoreSoapNamespace() throws ConfigurationException {
SoapWrapper soapWrapper = SoapWrapper.getInstance();
String soapMessage = soapMessageSoap11;
String expectedSoapBody = expectedSoapBody11;
String soapBody = null;
PipeLineSession session = new PipeLineSession();
String sessionKey = "SoapVersion";
try {
soapBody = soapWrapper.getBody(new Message(soapMessage), true, session, sessionKey).asString();
} catch (Exception e) {
soapBody = e.getMessage();
}
assertEquals(expectedSoapBody, soapBody);
String soapVersion = (String) session.get(sessionKey);
assertEquals(SoapVersion.SOAP11.namespace, soapVersion);
}
Aggregations