Search in sources :

Example 76 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class ParameterTest method testDefaultValueMethodMulti.

@Test
public void testDefaultValueMethodMulti() throws Exception {
    Parameter p = new Parameter();
    p.setXpathExpression("*/*");
    p.setValue("<doc/>");
    p.setDefaultValue("fakeDefaultValue");
    p.setPattern("{sessionKeyForPattern}");
    p.setDefaultValueMethods("sessionKey,value,pattern");
    p.configure();
    PipeLineSession session = new PipeLineSession();
    session.put("sessionKeyForDefaultValue", "fakeDefaultValueSessionKey");
    session.put("sessionKeyForPattern", "fakePatternSessionKey");
    ParameterValueList alreadyResolvedParameters = new ParameterValueList();
    Message message = new Message("fakeMessage");
    String result = (String) p.getValue(alreadyResolvedParameters, message, session, false);
    assertEquals("<doc/>", result);
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 77 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class ParameterTest method testDefaultValueMethodDefault.

@Test
public void testDefaultValueMethodDefault() throws Exception {
    Parameter p = new Parameter();
    p.setXpathExpression("*/*");
    p.setValue("<doc/>");
    p.setDefaultValue("fakeDefaultValue");
    p.setSessionKey("sessionKeyForDefaultValue");
    p.setPattern("{sessionKeyForPattern}");
    p.configure();
    PipeLineSession session = new PipeLineSession();
    session.put("sessionKeyForDefaultValue", "fakeDefaultValueSessionKey");
    session.put("sessionKeyForPattern", "fakePatternSessionKey");
    ParameterValueList alreadyResolvedParameters = new ParameterValueList();
    Message message = new Message("fakeMessage");
    String result = (String) p.getValue(alreadyResolvedParameters, message, session, false);
    assertEquals("fakeDefaultValue", result);
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 78 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class ParameterTest method testParameterFromBytesToNode.

@Test
public void testParameterFromBytesToNode() throws Exception {
    PipeLineSession session = new PipeLineSession();
    session.put("originalMessage", "<someValue/>".getBytes());
    String expectedResultContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><someValue/>";
    Parameter parameter = new Parameter();
    parameter.setName("InputMessage");
    parameter.setSessionKey("originalMessage");
    parameter.setType(ParameterType.NODE);
    parameter.configure();
    ParameterValueList alreadyResolvedParameters = new ParameterValueList();
    Message message = new Message("fakeMessage");
    Object result = parameter.getValue(alreadyResolvedParameters, message, session, true);
    assertThat(result, instanceOf(Node.class));
    assertThat(result, not(instanceOf(Document.class)));
    String contents = XmlUtils.transformXml(TransformerFactory.newInstance().newTransformer(), new DOMSource((Node) result));
    assertEquals(expectedResultContents, contents);
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) Message(nl.nn.adapterframework.stream.Message) Node(org.w3c.dom.Node) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 79 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class ParameterTest method testParameterFromNodeToDomdoc.

@Test
public void testParameterFromNodeToDomdoc() throws Exception {
    Node node = XmlUtils.buildDomDocument("<someValue/>").getFirstChild();
    String expectedResultContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><someValue/>";
    PipeLineSession session = new PipeLineSession();
    session.put("originalMessage", node);
    Parameter parameter = new Parameter();
    parameter.setName("InputMessage");
    parameter.setSessionKey("originalMessage");
    parameter.setType(ParameterType.DOMDOC);
    parameter.configure();
    ParameterValueList alreadyResolvedParameters = new ParameterValueList();
    Message message = new Message("fakeMessage");
    Object result = parameter.getValue(alreadyResolvedParameters, message, session, true);
    assertThat(result, instanceOf(Document.class));
    String contents = XmlUtils.transformXml(TransformerFactory.newInstance().newTransformer(), new DOMSource((Document) result));
    assertEquals(expectedResultContents, contents);
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) Message(nl.nn.adapterframework.stream.Message) Node(org.w3c.dom.Node) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 80 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.

the class ParameterTest method testParameterXPathEmptySessionKey.

@Test
public void testParameterXPathEmptySessionKey() throws Exception {
    Parameter p = new Parameter();
    p.setName("number");
    p.setSessionKey("emptySessionKey");
    p.setXpathExpression("/dummy");
    p.setDefaultValue("fakeDefault");
    p.configure();
    ParameterValueList alreadyResolvedParameters = new ParameterValueList();
    Message message = new Message("fakeMessage");
    PipeLineSession session = new PipeLineSession();
    session.put("emptySessionKey", "");
    Object result = p.getValue(alreadyResolvedParameters, message, session, false);
    assertEquals("fakeDefault", Message.asMessage(result).asString());
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Aggregations

PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)270 Message (nl.nn.adapterframework.stream.Message)210 Test (org.junit.Test)202 SenderException (nl.nn.adapterframework.core.SenderException)43 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)33 UrlMessage (nl.nn.adapterframework.stream.UrlMessage)30 ByteArrayInputStream (java.io.ByteArrayInputStream)26 IOException (java.io.IOException)25 Parameter (nl.nn.adapterframework.parameters.Parameter)23 PipeForward (nl.nn.adapterframework.core.PipeForward)21 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)17 Date (java.util.Date)15 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)14 InputStream (java.io.InputStream)11 TimeoutException (nl.nn.adapterframework.core.TimeoutException)11 ParameterList (nl.nn.adapterframework.parameters.ParameterList)11 Map (java.util.Map)10 SimpleDateFormat (java.text.SimpleDateFormat)9 SOAPMessage (javax.xml.soap.SOAPMessage)9 URL (java.net.URL)8