Search in sources :

Example 1 with EchoSender

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);
}
Also used : PipeForward(nl.nn.adapterframework.core.PipeForward) SenderSeries(nl.nn.adapterframework.senders.SenderSeries) EchoSender(nl.nn.adapterframework.senders.EchoSender) Before(org.junit.Before)

Example 2 with EchoSender

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;
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) IOException(java.io.IOException) SenderException(nl.nn.adapterframework.core.SenderException) EchoSender(nl.nn.adapterframework.senders.EchoSender) TimeoutException(nl.nn.adapterframework.core.TimeoutException)

Example 3 with EchoSender

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);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) Message(nl.nn.adapterframework.stream.Message) CorePipeProcessor(nl.nn.adapterframework.processors.CorePipeProcessor) EchoSender(nl.nn.adapterframework.senders.EchoSender) Test(org.junit.Test)

Example 4 with EchoSender

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());
}
Also used : Message(nl.nn.adapterframework.stream.Message) EchoSender(nl.nn.adapterframework.senders.EchoSender) Test(org.junit.Test)

Example 5 with EchoSender

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;
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) IOException(java.io.IOException) SenderException(nl.nn.adapterframework.core.SenderException) EchoSender(nl.nn.adapterframework.senders.EchoSender)

Aggregations

EchoSender (nl.nn.adapterframework.senders.EchoSender)5 Message (nl.nn.adapterframework.stream.Message)4 IOException (java.io.IOException)2 PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)2 SenderException (nl.nn.adapterframework.core.SenderException)2 Test (org.junit.Test)2 PipeForward (nl.nn.adapterframework.core.PipeForward)1 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)1 TimeoutException (nl.nn.adapterframework.core.TimeoutException)1 CorePipeProcessor (nl.nn.adapterframework.processors.CorePipeProcessor)1 SenderSeries (nl.nn.adapterframework.senders.SenderSeries)1 Before (org.junit.Before)1