Search in sources :

Example 36 with PipeLineSession

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

the class MultipartHttpSenderTest method simpleMockedMultipartHttp1.

@Test
public void simpleMockedMultipartHttp1() throws Throwable {
    MultipartHttpSender sender = getSender();
    Message input = new Message("<xml>input</xml>");
    try {
        PipeLineSession pls = new PipeLineSession(session);
        String xmlMultipart = "<parts><part type=\"file\" name=\"document.pdf\" " + "sessionKey=\"part_file\" size=\"72833\" " + "mimeType=\"application/pdf\"/></parts>";
        pls.put("multipartXml", xmlMultipart);
        pls.put("part_file", new ByteArrayInputStream("<dummy xml file/>".getBytes()));
        sender.setMultipartXmlSessionKey("multipartXml");
        sender.configure();
        sender.open();
        String result = sender.sendMessage(input, pls).asString();
        assertEqualsIgnoreCRLF(getFile("simpleMockedMultipartHttp1.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    } finally {
        if (sender != null) {
            sender.close();
        }
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) ByteArrayInputStream(java.io.ByteArrayInputStream) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SenderException(nl.nn.adapterframework.core.SenderException) Test(org.junit.Test)

Example 37 with PipeLineSession

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

the class MultipartHttpSenderTest method simpleMockedMultipartHttp2.

@Test
public void simpleMockedMultipartHttp2() throws Throwable {
    MultipartHttpSender sender = getSender();
    Message input = new Message("<xml>input</xml>");
    try {
        PipeLineSession pls = new PipeLineSession(session);
        String xmlMultipart = "<parts><part name=\"dummy\" filename=\"document.pdf\" " + "sessionKey=\"part_file\" size=\"72833\" " + "mimeType=\"application/pdf\"/></parts>";
        pls.put("multipartXml", xmlMultipart);
        pls.put("part_file", new ByteArrayInputStream("<dummy xml file/>".getBytes()));
        sender.setMultipartXmlSessionKey("multipartXml");
        sender.configure();
        sender.open();
        String result = sender.sendMessage(input, pls).asString();
        assertEqualsIgnoreCRLF(getFile("simpleMockedMultipartHttp2.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    } finally {
        if (sender != null) {
            sender.close();
        }
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) ByteArrayInputStream(java.io.ByteArrayInputStream) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SenderException(nl.nn.adapterframework.core.SenderException) Test(org.junit.Test)

Example 38 with PipeLineSession

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

the class MultipartHttpSenderTest method simpleMockedMultipartMtom2.

@Test
public void simpleMockedMultipartMtom2() throws Throwable {
    MultipartHttpSender sender = getSender();
    Message input = new Message("<xml>input</xml>");
    try {
        PipeLineSession pls = new PipeLineSession(session);
        String xmlMultipart = "<parts><part name=\"dummy\" filename=\"document.pdf\" " + "sessionKey=\"part_file\" size=\"72833\" " + "mimeType=\"application/pdf\"/></parts>";
        pls.put("multipartXml", xmlMultipart);
        pls.put("part_file", new ByteArrayInputStream("<dummy xml file/>".getBytes()));
        sender.setMtomEnabled(true);
        sender.setMultipartXmlSessionKey("multipartXml");
        sender.configure();
        sender.open();
        String result = sender.sendMessage(input, pls).asString();
        assertEqualsIgnoreCRLF(getFile("simpleMockedMultipartMtom2.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    } finally {
        if (sender != null) {
            sender.close();
        }
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) ByteArrayInputStream(java.io.ByteArrayInputStream) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SenderException(nl.nn.adapterframework.core.SenderException) Test(org.junit.Test)

Example 39 with PipeLineSession

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

the class RestSenderTest method simpleMockedHttpPost.

@Test
public void simpleMockedHttpPost() throws Throwable {
    // Cannot add headers (aka parameters) for this test!
    RestSender sender = getSender(false);
    Message input = new Message("hallo this is my message");
    PipeLineSession pls = new PipeLineSession(session);
    // should handle both upper and lowercase methodtypes :)
    sender.setMethodType(HttpMethod.POST);
    sender.configure();
    sender.open();
    String result = sender.sendMessage(input, pls).asString().replaceAll("&#xD;", "\r");
    assertEqualsIgnoreCRLF(getFile("simpleMockedRestPost.txt"), result.trim());
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 40 with PipeLineSession

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

the class WebServiceSenderTest method simpleMockedWss.

@Test
public void simpleMockedWss() throws Throwable {
    WebServiceSender sender = getSender();
    Message input = new Message("<hallo/>");
    try {
        PipeLineSession pls = new PipeLineSession(session);
        sender.configure();
        sender.open();
        String result = sender.sendMessage(input, pls).asString();
        assertEqualsIgnoreCRLF(getFile("simpleMockedWss.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SenderException(nl.nn.adapterframework.core.SenderException) 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