Search in sources :

Example 1 with CorePipeProcessor

use of nl.nn.adapterframework.processors.CorePipeProcessor in project iaf by ibissource.

the class PipeLineTest method testDirectWrapperPipeSuccessForward.

// Should add tests to assertThat(configuration.getConfigWarning(0), StringEndsWith.endsWith("] has no pipe forwards defined"));
@Test
public void testDirectWrapperPipeSuccessForward() throws ConfigurationException, PipeRunException {
    TestConfiguration configuration = new TestConfiguration();
    PipeLine pipeline = configuration.createBean(PipeLine.class);
    PipeForward pf = configuration.createBean(PipeForward.class);
    pf.setName("success");
    pf.setPath("nextPipe");
    PipeForward toExit = configuration.createBean(PipeForward.class);
    toExit.setName("success");
    toExit.setPath("EXIT");
    DirectWrapperPipe pipe = configuration.createBean(DirectWrapperPipe.class);
    pipe.setName("DirectWrapperPipe");
    pipe.registerForward(pf);
    pipeline.addPipe(pipe);
    EchoPipe echoPipe = configuration.createBean(EchoPipe.class);
    echoPipe.setName("nextPipe");
    echoPipe.setPipeLine(pipeline);
    echoPipe.registerForward(toExit);
    pipeline.addPipe(echoPipe);
    PipeLineExit exit = configuration.createBean(PipeLineExit.class);
    exit.setPath("exit");
    exit.setState(ExitState.SUCCESS);
    pipeline.registerPipeLineExit(exit);
    pipeline.setOwner(pipe);
    pipeline.configure();
    CorePipeProcessor cpp = configuration.createBean(CorePipeProcessor.class);
    PipeLineSession ps = configuration.createBean(PipeLineSession.class);
    PipeRunResult pipeRunResult = cpp.processPipe(pipeline, pipe, new Message("<dummy/>"), ps);
    PipeForward pipeForward = pipeRunResult.getPipeForward();
    IForwardTarget target = pipeline.resolveForward(pipe, pipeForward);
    assertNotNull(target);
    configuration.close();
    configuration = null;
}
Also used : Message(nl.nn.adapterframework.stream.Message) EchoPipe(nl.nn.adapterframework.pipes.EchoPipe) CorePipeProcessor(nl.nn.adapterframework.processors.CorePipeProcessor) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) DirectWrapperPipe(nl.nn.adapterframework.extensions.esb.DirectWrapperPipe) Test(org.junit.Test)

Example 2 with CorePipeProcessor

use of nl.nn.adapterframework.processors.CorePipeProcessor in project iaf by ibissource.

the class ParameterTest method testPutInSessionPipeWithDomdocParamsUsedMoreThanOnce.

@Test
public // Test for #2256 PutParametersInSession with xpathExpression with type=domdoc results in "Content is not allowed in prolog"
void testPutInSessionPipeWithDomdocParamsUsedMoreThanOnce() throws Exception {
    try (TestConfiguration configuration = new TestConfiguration()) {
        PipeLine pipeline = configuration.createBean(PipeLine.class);
        String firstPipe = "PutInSession under test";
        String secondPipe = "PutInSession next pipe";
        String testMessage = "<Test>\n" + "	<Child><name>X</name></Child>\n" + "	<Child><name>Y</name></Child>\n" + "	<Child><name>Z</name></Child>\n" + "</Test>";
        String testMessageChild1 = "<Child><name>X</name></Child>";
        PutInSession pipe = configuration.createBean(PutInSession.class);
        pipe.setName(firstPipe);
        pipe.setPipeLine(pipeline);
        Parameter p = new Parameter();
        p.setName("xmlMessageChild");
        p.setXpathExpression("Test/Child[1]");
        p.setType(ParameterType.DOMDOC);
        pipe.addParameter(p);
        pipeline.addPipe(pipe);
        PutInSession pipe2 = configuration.createBean(PutInSession.class);
        pipe2.setName(secondPipe);
        pipe2.setPipeLine(pipeline);
        Parameter p2 = new Parameter();
        p2.setName("xmlMessageChild2");
        p2.setSessionKey("xmlMessageChild");
        p2.setXpathExpression("Child/name/text()");
        pipe2.addParameter(p2);
        pipeline.addPipe(pipe2);
        PipeLineExit exit = new PipeLineExit();
        exit.setPath("exit");
        exit.setState(ExitState.SUCCESS);
        pipeline.registerPipeLineExit(exit);
        pipeline.configure();
        CorePipeLineProcessor cpp = configuration.createBean(CorePipeLineProcessor.class);
        CorePipeProcessor pipeProcessor = configuration.createBean(CorePipeProcessor.class);
        cpp.setPipeProcessor(pipeProcessor);
        PipeLineSession session = configuration.createBean(PipeLineSession.class);
        pipeline.setOwner(pipe);
        PipeLineResult pipeRunResult = cpp.processPipeLine(pipeline, "messageId", new Message(testMessage), session, firstPipe);
        assertEquals(ExitState.SUCCESS, pipeRunResult.getState());
        assertEquals(testMessage, pipeRunResult.getResult().asString());
        MatchUtils.assertXmlEquals(testMessageChild1, session.getMessage("xmlMessageChild").asString());
        assertEquals("X", session.getMessage("xmlMessageChild2").asString());
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) CorePipeProcessor(nl.nn.adapterframework.processors.CorePipeProcessor) PipeLineResult(nl.nn.adapterframework.core.PipeLineResult) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) PipeLine(nl.nn.adapterframework.core.PipeLine) PutInSession(nl.nn.adapterframework.pipes.PutInSession) CorePipeLineProcessor(nl.nn.adapterframework.processors.CorePipeLineProcessor) PipeLineExit(nl.nn.adapterframework.core.PipeLineExit) Test(org.junit.Test)

Example 3 with CorePipeProcessor

use of nl.nn.adapterframework.processors.CorePipeProcessor in project iaf by ibissource.

the class MessageSendingPipeTest method testInputValidated.

@Test
public void testInputValidated() throws Exception {
    Json2XmlValidator validator = new Json2XmlValidator();
    validator.setNoNamespaceSchemaLocation("/Align/Abc/abc.xsd");
    validator.setOutputFormat(DocumentFormat.JSON);
    validator.setThrowException(true);
    pipe.setInputValidator(validator);
    pipe.setPipeProcessor(new CorePipeProcessor());
    configureAndStartPipe();
    Message input = TestFileUtils.getTestFileMessage("/Align/Abc/abc.xml");
    String expected = "{ \"input\": \"" + TestFileUtils.getTestFile("/Align/Abc/abc-compact.json") + "\"}";
    PipeRunResult prr = doPipe(input);
    assertEquals("success", prr.getPipeForward().getName());
    assertEquals(expected, prr.getResult().asString());
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) Message(nl.nn.adapterframework.stream.Message) CorePipeProcessor(nl.nn.adapterframework.processors.CorePipeProcessor) Test(org.junit.Test)

Example 4 with CorePipeProcessor

use of nl.nn.adapterframework.processors.CorePipeProcessor 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 5 with CorePipeProcessor

use of nl.nn.adapterframework.processors.CorePipeProcessor in project iaf by ibissource.

the class MessageSendingPipeTest method testOutputWrapped.

@Test
public void testOutputWrapped() throws Exception {
    pipe.setOutputWrapper(new SoapWrapperPipe());
    pipe.setPipeProcessor(new CorePipeProcessor());
    configureAndStartPipe();
    PipeRunResult prr = doPipe("testMessage");
    assertEquals("success", prr.getPipeForward().getName());
    String expected = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Body>{ \"input\": \"testMessage\"}</soapenv:Body></soapenv:Envelope>";
    assertEquals(expected, prr.getResult().asString());
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) CorePipeProcessor(nl.nn.adapterframework.processors.CorePipeProcessor) SoapWrapperPipe(nl.nn.adapterframework.soap.SoapWrapperPipe) Test(org.junit.Test)

Aggregations

CorePipeProcessor (nl.nn.adapterframework.processors.CorePipeProcessor)6 Test (org.junit.Test)6 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)4 Message (nl.nn.adapterframework.stream.Message)4 SoapWrapperPipe (nl.nn.adapterframework.soap.SoapWrapperPipe)2 TestConfiguration (nl.nn.adapterframework.testutil.TestConfiguration)2 PipeLine (nl.nn.adapterframework.core.PipeLine)1 PipeLineExit (nl.nn.adapterframework.core.PipeLineExit)1 PipeLineResult (nl.nn.adapterframework.core.PipeLineResult)1 PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)1 DirectWrapperPipe (nl.nn.adapterframework.extensions.esb.DirectWrapperPipe)1 EchoPipe (nl.nn.adapterframework.pipes.EchoPipe)1 PutInSession (nl.nn.adapterframework.pipes.PutInSession)1 CorePipeLineProcessor (nl.nn.adapterframework.processors.CorePipeLineProcessor)1 EchoSender (nl.nn.adapterframework.senders.EchoSender)1