Search in sources :

Example 41 with PipeLineSession

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

the class WebServiceSenderTest method simpleMockedWssMultipart.

@Test
public void simpleMockedWssMultipart() throws Throwable {
    WebServiceSender sender = getSender();
    Message input = new Message("<xml>input</xml>");
    try {
        PipeLineSession pls = new PipeLineSession(session);
        sender.setMethodType(HttpMethod.POST);
        sender.setParamsInUrl(false);
        sender.setInputMessageParam("request");
        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("simpleMockedWssMultipart.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    }
}
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 42 with PipeLineSession

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

the class WebServiceSenderTest method simpleMockedWssMultipart2.

@Test
public void simpleMockedWssMultipart2() throws Throwable {
    WebServiceSender sender = getSender();
    Message input = new Message("<xml>input</xml>");
    try {
        PipeLineSession pls = new PipeLineSession(session);
        sender.setMethodType(HttpMethod.POST);
        sender.setParamsInUrl(false);
        sender.setInputMessageParam("request");
        String xmlMultipart = "<parts>" + "<part type=\"file\" name=\"document1.pdf\" sessionKey=\"part_file1\" mimeType=\"application/pdf\"/>" + "<part type=\"file\" name=\"document2.pdf\" sessionKey=\"part_file2\" mimeType=\"application/pdf\"/>" + "</parts>";
        pls.put("multipartXml", xmlMultipart);
        pls.put("part_file1", new ByteArrayInputStream("<dummy pdf file/>".getBytes()));
        pls.put("part_file2", new ByteArrayInputStream("<dummy pdf file/>".getBytes()));
        sender.setMultipartXmlSessionKey("multipartXml");
        sender.configure();
        sender.open();
        String result = sender.sendMessage(input, pls).asString();
        ;
        assertEqualsIgnoreCRLF(getFile("simpleMockedWssMultipart2.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    }
}
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 43 with PipeLineSession

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

the class WebServiceSenderTest method simpleMockedWssMtom.

@Test
public void simpleMockedWssMtom() throws Throwable {
    WebServiceSender sender = getSender();
    Message input = new Message("<xml>input</xml>");
    try {
        PipeLineSession pls = new PipeLineSession(session);
        sender.setMethodType(HttpMethod.POST);
        sender.setParamsInUrl(false);
        sender.setInputMessageParam("request");
        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.setMtomEnabled(true);
        sender.setMultipartXmlSessionKey("multipartXml");
        sender.configure();
        sender.open();
        String result = sender.sendMessage(input, pls).asString();
        assertEqualsIgnoreCRLF(getFile("simpleMockedWssMtom.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    }
}
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 44 with PipeLineSession

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

the class HttpSenderTest method simpleMockedHttpGet.

@Test
public void simpleMockedHttpGet() throws Throwable {
    // Cannot add headers (aka parameters) for this test!
    sender = getSender(false);
    Message input = new Message("hallo");
    PipeLineSession pls = new PipeLineSession(session);
    sender.setMethodType(HttpMethod.GET);
    sender.configure();
    sender.open();
    String result = sender.sendMessage(input, pls).asString();
    assertEqualsIgnoreCRLF(getFile("simpleMockedHttpGet.txt"), result.trim());
}
Also used : Message(nl.nn.adapterframework.stream.Message) UrlMessage(nl.nn.adapterframework.stream.UrlMessage) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 45 with PipeLineSession

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

the class HttpSenderTest method simpleMockedHttpPostAppendParamsToBodyAndEmptyBody.

@Test
public void simpleMockedHttpPostAppendParamsToBodyAndEmptyBody() throws Throwable {
    // Cannot add headers (aka parameters) for this test!
    sender = getSender(false);
    sender.setUrl("http://127.0.0.1/something&dummy=true");
    Message input = new Message("");
    PipeLineSession pls = new PipeLineSession(session);
    // should handle both upper and lowercase methodtypes :)
    sender.setMethodType(HttpMethod.POST);
    sender.addParameter(new Parameter("key", "value"));
    sender.addParameter(new Parameter("otherKey", "otherValue"));
    sender.configure();
    sender.open();
    String result = sender.sendMessage(input, pls).asString();
    assertEqualsIgnoreCRLF(getFile("simpleMockedHttpPostAppendParamsToBodyAndEmptyBody.txt"), result.trim());
}
Also used : Message(nl.nn.adapterframework.stream.Message) UrlMessage(nl.nn.adapterframework.stream.UrlMessage) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Parameter(nl.nn.adapterframework.parameters.Parameter) 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