use of nl.nn.adapterframework.pipes.PutInSession 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());
}
}
Aggregations