Search in sources :

Example 1 with XsltSender

use of nl.nn.adapterframework.senders.XsltSender in project iaf by ibissource.

the class ForEachChildElementPipeTest method testElementChain.

// The XmlFileElementIteratorPipe has been deprecated, elementChain has been replaced with targetElement + containerElement.
// This test proves that the old method works with the ForEachChildElemenPipe.
// The xPath in the sender was adjusted to match the targetElement
@Test
public void testElementChain() throws Exception {
    XsltSender sender = new XsltSender();
    sender.setXpathExpression("concat(Party/Person/PersonName/Id,'_',Party/Person/Demographics/Gender)");
    pipe.setProcessFile(true);
    pipe.setSender(sender);
    pipe.setContainerElement("PartyInternalAgreementRole");
    pipe.setTargetElement("Party");
    pipe.configure();
    pipe.start();
    URL input = TestFileUtils.getTestFileURL("/XmlFileElementIteratorPipe/input.xml");
    File file = new File(input.toURI());
    String expected = TestFileUtils.getTestFile("/XmlFileElementIteratorPipe/ElementChainOutput.xml");
    PipeRunResult prr = doPipe(pipe, file.toString(), session);
    String result = Message.asString(prr.getResult());
    TestAssertions.assertEqualsIgnoreCRLF(expected, result);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) XsltSender(nl.nn.adapterframework.senders.XsltSender) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 2 with XsltSender

use of nl.nn.adapterframework.senders.XsltSender in project iaf by ibissource.

the class XmlFileElementIteratorPipeTest method testElementName.

@Test
public void testElementName() throws Exception {
    XsltSender sender = new XsltSender();
    sender.setXpathExpression("concat(Person/PersonName/Id,'_',Person/Demographics/Gender)");
    pipe.setSender(sender);
    pipe.setElementName("Person");
    pipe.configure();
    pipe.start();
    URL input = TestFileUtils.getTestFileURL("/XmlFileElementIteratorPipe/input.xml");
    File file = new File(input.toURI());
    String expected = TestFileUtils.getTestFile("/XmlFileElementIteratorPipe/ElementNameOutput.xml");
    PipeRunResult prr = doPipe(pipe, file.toString(), session);
    String result = Message.asString(prr.getResult());
    TestAssertions.assertEqualsIgnoreCRLF(expected, result);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) XsltSender(nl.nn.adapterframework.senders.XsltSender) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 3 with XsltSender

use of nl.nn.adapterframework.senders.XsltSender in project iaf by ibissource.

the class ParallelXsltTest method createPipe.

@Override
public SenderPipe createPipe() {
    SenderPipe pipe = new SenderPipe();
    SenderSeries psenders = createSenderContainer();
    xsltSenders = new ArrayList<XsltSender>();
    for (int i = 0; i < NUM_SENDERS; i++) {
        XsltSender sender = new XsltSender();
        // sender.setSessionKey("out"+i);
        sender.setOmitXmlDeclaration(true);
        sender.addParameter(new Parameter("header", "header" + i));
        session.put("sessionKey" + i, "sessionKeyValue" + i);
        sender.addParameter(ParameterBuilder.create().withName("sessionKey").withSessionKey("sessionKey" + i));
        autowireByType(sender);
        psenders.registerSender(sender);
        xsltSenders.add(sender);
    }
    session.put("sessionKeyGlobal", "sessionKeyGlobalValue");
    psenders.addParameter(ParameterBuilder.create().withName("sessionKeyGlobal").withSessionKey("sessionKeyGlobal"));
    pipe.setSender(psenders);
    return pipe;
}
Also used : SenderPipe(nl.nn.adapterframework.pipes.SenderPipe) Parameter(nl.nn.adapterframework.parameters.Parameter) XsltSender(nl.nn.adapterframework.senders.XsltSender) SenderSeries(nl.nn.adapterframework.senders.SenderSeries)

Example 4 with XsltSender

use of nl.nn.adapterframework.senders.XsltSender in project iaf by ibissource.

the class ForEachChildElementPipeTest method testElementName.

// The XmlFileElementIteratorPipe has been deprecated, elementName has been replaced by targetElement.
// This test proves that the old method works with the ForEachChildElemenPipe
@Test
public void testElementName() throws Exception {
    XsltSender sender = new XsltSender();
    sender.setXpathExpression("concat(Person/PersonName/Id,'_',Person/Demographics/Gender)");
    pipe.setProcessFile(true);
    pipe.setSender(sender);
    pipe.setTargetElement("Person");
    pipe.configure();
    pipe.start();
    URL input = TestFileUtils.getTestFileURL("/XmlFileElementIteratorPipe/input.xml");
    File file = new File(input.toURI());
    String expected = TestFileUtils.getTestFile("/XmlFileElementIteratorPipe/ElementNameOutput.xml");
    PipeRunResult prr = doPipe(pipe, file.toString(), session);
    String result = Message.asString(prr.getResult());
    TestAssertions.assertEqualsIgnoreCRLF(expected, result);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) XsltSender(nl.nn.adapterframework.senders.XsltSender) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 5 with XsltSender

use of nl.nn.adapterframework.senders.XsltSender in project iaf by ibissource.

the class XsltSenderTest method createPipe.

@Override
public SenderPipe createPipe() {
    SenderPipe pipe = new SenderPipe();
    sender = new XsltSender();
    autowireByType(sender);
    pipe.setSender(sender);
    return pipe;
}
Also used : SenderPipe(nl.nn.adapterframework.pipes.SenderPipe) XsltSender(nl.nn.adapterframework.senders.XsltSender)

Aggregations

XsltSender (nl.nn.adapterframework.senders.XsltSender)6 File (java.io.File)4 URL (java.net.URL)4 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)4 Test (org.junit.Test)4 SenderPipe (nl.nn.adapterframework.pipes.SenderPipe)2 Parameter (nl.nn.adapterframework.parameters.Parameter)1 SenderSeries (nl.nn.adapterframework.senders.SenderSeries)1