Search in sources :

Example 81 with PipeLineSession

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

the class ParameterTest method testFixedDateWithSessionFromTesttool.

@Test
public void testFixedDateWithSessionFromTesttool() throws Exception {
    Parameter p = new Parameter();
    p.setName("date");
    p.setPattern("{fixedDate}");
    p.setType(ParameterType.DATE);
    p.configure();
    PipeLineSession session = new PipeLineSession();
    session.put("stub4testtool.fixeddate", "1996-02-24");
    ParameterValueList alreadyResolvedParameters = new ParameterValueList();
    Message message = new Message("fakeMessage");
    try {
        System.setProperty(ConfigurationUtils.STUB4TESTTOOL_CONFIGURATION_KEY, "true");
        Object result = p.getValue(alreadyResolvedParameters, message, session, false);
        assertTrue(result instanceof Date);
        Date resultDate = (Date) result;
        SimpleDateFormat sdf = new SimpleDateFormat(Parameter.TYPE_DATE_PATTERN);
        String formattedDate = sdf.format(resultDate);
        assertEquals("1996-02-24", formattedDate);
    } finally {
        System.setProperty(ConfigurationUtils.STUB4TESTTOOL_CONFIGURATION_KEY, "false");
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 82 with PipeLineSession

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

the class SoapProviderTest method receiveMessageWithAttachmentsTest.

@Test
public /**
 * Receive SOAP message with MTOM attachment
 * Reply SOAP message without attachment
 * @throws Throwable
 */
void receiveMessageWithAttachmentsTest() throws Throwable {
    SOAPMessage request = createMessage("correct-soapmsg.xml", true, false);
    SOAPMessage message = SOAPProvider.invoke(request);
    String result = XmlUtils.nodeToString(message.getSOAPPart());
    String expected = Misc.streamToString(getFile("correct-soapmsg.xml"));
    assertEquals(expected.replaceAll("\r", ""), result.replaceAll("\r", ""));
    PipeLineSession session = SOAPProvider.getSession();
    assertAttachmentInSession(session);
}
Also used : PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SOAPMessage(javax.xml.soap.SOAPMessage) Test(org.junit.Test)

Example 83 with PipeLineSession

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

the class SoapProviderTest method simpleMessageTest.

@Test
public /**
 * Receive SOAP message without attachment
 * Reply SOAP message without attachment
 * @throws Throwable
 */
void simpleMessageTest() throws Throwable {
    SOAPMessage request = createMessage("correct-soapmsg.xml");
    SOAPMessage message = SOAPProvider.invoke(request);
    String result = XmlUtils.nodeToString(message.getSOAPPart());
    String expected = Misc.streamToString(getFile("correct-soapmsg.xml"));
    assertEquals(expected.replaceAll("\r", ""), result.replaceAll("\r", ""));
    PipeLineSession session = SOAPProvider.getSession();
    assertNotNull(session.get("mimeHeaders"));
    assertNotNull(session.get("attachments"));
    assertEquals("<attachments/>", session.get("attachments").toString().trim());
}
Also used : PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SOAPMessage(javax.xml.soap.SOAPMessage) Test(org.junit.Test)

Example 84 with PipeLineSession

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

the class GetFromSessionTest method populateSession.

@Before
public void populateSession() {
    session = new PipeLineSession();
    session.put("dummyString", DUMMY_DATA);
    session.put("dummyByteArray", DUMMY_DATA.getBytes());
    session.put("dummyStream", new ByteArrayInputStream(DUMMY_DATA.getBytes()));
    session.put("emptyMap", new HashMap<String, String>());
    Map<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    session.put("map", map);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) HashMap(java.util.HashMap) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Before(org.junit.Before)

Example 85 with PipeLineSession

use of nl.nn.adapterframework.core.PipeLineSession 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)

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