use of nl.nn.adapterframework.senders.EchoSender in project iaf by ibissource.
the class ForEachAttachmentPipeTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
pipe = createForEachAttachmentPipe();
pipe.registerForward(new PipeForward("success", null));
SenderSeries series = new SenderSeries();
series.registerSender(new EchoSender());
pipe.setSender(series);
}
use of nl.nn.adapterframework.senders.EchoSender in project iaf by ibissource.
the class MessageSendingPipeTest method createPipe.
@Override
public MessageSendingPipe createPipe() throws ConfigurationException {
MessageSendingPipe result = new MessageSendingPipe();
result.setSender(new EchoSender() {
@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
try {
return new Message("{ \"input\": \"" + message.asString() + "\"}");
} catch (IOException e) {
throw new SenderException(e);
}
}
});
return result;
}
use of nl.nn.adapterframework.senders.EchoSender in project iaf by ibissource.
the class MessageSendingPipeTest method testOutputValidated.
@Test
public void testOutputValidated() throws Exception {
Json2XmlValidator validator = new Json2XmlValidator();
validator.setNoNamespaceSchemaLocation("/Align/Abc/abc.xsd");
validator.setRoot("a");
validator.setOutputFormat(DocumentFormat.XML);
validator.setThrowException(true);
pipe.setOutputValidator(validator);
pipe.setSender(new EchoSender());
pipe.setPipeProcessor(new CorePipeProcessor());
configureAndStartPipe();
Message input = TestFileUtils.getTestFileMessage("/Align/Abc/abc-compact.json");
String expected = TestFileUtils.getTestFile("/Align/Abc/abc.xml");
PipeRunResult prr = doPipe(input);
assertEquals("success", prr.getPipeForward().getName());
assertXmlEquals("response converted", expected, prr.getResult().asString(), true);
}
use of nl.nn.adapterframework.senders.EchoSender in project iaf by ibissource.
the class JavascriptSenderCallbackTest method javaScriptSenderWithNestedEchoSender.
// An EchoSender will be called in the javascript code.
@Test
public void javaScriptSenderWithNestedEchoSender() throws ConfigurationException, SenderException, TimeoutException, IOException {
Message dummyInput = new Message("dummyinput");
sender.setJsFileName("Javascript/JavascriptTest.js");
sender.setJsFunctionName("f4");
sender.setEngineName(engine);
sender.addParameter(ParameterBuilder.create("x", "3").withType(ParameterType.INTEGER));
sender.addParameter(ParameterBuilder.create("y", "4").withType(ParameterType.INTEGER));
EchoSender log = new EchoSender();
log.setName("myFunction");
sender.registerSender(log);
sender.configure();
sender.open();
// See function 4, validates if input to the nested sender is the same as the output of the nested sender
assertEquals("true", sender.sendMessage(dummyInput, session).asString());
}
use of nl.nn.adapterframework.senders.EchoSender in project iaf by ibissource.
the class IteratingPipeTest method getElementRenderer.
protected ISender getElementRenderer(final Exception e) {
EchoSender sender = new EchoSender() {
@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
try {
if (message.asString().contains("error")) {
throw new SenderException("Exception triggered", e);
}
String result = "[" + message.asString() + "]";
resultLog.append(result + "\n");
return new Message(result);
} catch (IOException e) {
throw new SenderException(getLogPrefix(), e);
}
}
};
return sender;
}
Aggregations