Search in sources :

Example 51 with PipeLineSession

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

the class HttpSenderTest method paramsWithoutValue.

@Test
public void paramsWithoutValue() throws Throwable {
    sender = getSender();
    Message input = new Message("paramterValue");
    PipeLineSession pls = new PipeLineSession(session);
    sender.addParameter(new Parameter("url", "http://127.0.0.1/value%2Fvalue?emptyParam"));
    sender.addParameter(new Parameter("myParam", ""));
    sender.setMethodType(HttpMethod.GET);
    sender.configure();
    sender.open();
    String result = sender.sendMessage(input, pls).asString();
    assertEqualsIgnoreCRLF(getFile("paramsWithoutValue.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)

Example 52 with PipeLineSession

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

the class HttpSenderTest method binaryHttpPostJSON.

@Test
public void binaryHttpPostJSON() throws Throwable {
    sender = getSender();
    // Let's pretend this is a big JSON stream!
    Message input = new Message(new ByteArrayInputStream("{\"key1\": \"value2\"}".getBytes()));
    assertTrue("input message has to be of type binary", input.isBinary());
    PipeLineSession pls = new PipeLineSession(session);
    sender.setMethodType(HttpMethod.POST);
    sender.setContentType("application/json");
    sender.setPostType(PostType.BINARY);
    sender.configure();
    sender.open();
    String result = sender.sendMessage(input, pls).asString();
    assertEqualsIgnoreCRLF(getFile("binaryHttpPostJSON.txt"), result);
}
Also used : Message(nl.nn.adapterframework.stream.Message) UrlMessage(nl.nn.adapterframework.stream.UrlMessage) ByteArrayInputStream(java.io.ByteArrayInputStream) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 53 with PipeLineSession

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

the class HttpSenderTest method specialCharactersInURLParam.

@Test
public void specialCharactersInURLParam() throws Throwable {
    sender = getSender();
    Message input = new Message("hallo");
    PipeLineSession pls = new PipeLineSession(session);
    sender.addParameter(new Parameter("url", "http://127.0.0.1/value%20value?param=Hello%20G%C3%BCnter"));
    sender.addParameter(new Parameter("otherKey", "otherValue"));
    sender.setMethodType(HttpMethod.GET);
    sender.configure();
    sender.open();
    String result = sender.sendMessage(input, pls).asString();
    assertEqualsIgnoreCRLF(getFile("specialCharactersInURLParam.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)

Example 54 with PipeLineSession

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

the class HttpSenderTest method simpleMockedHttpUnknownHeaderParam.

@Test
public void simpleMockedHttpUnknownHeaderParam() throws Throwable {
    sender = getSender();
    Message input = new Message("hallo");
    PipeLineSession pls = new PipeLineSession(session);
    sender.addParameter(new Parameter("key", "value"));
    sender.addParameter(new Parameter("otherKey", "otherValue"));
    sender.setMethodType(HttpMethod.GET);
    sender.setHeadersParams("custom-header, doesn-t-exist");
    sender.configure();
    sender.open();
    String result = sender.sendMessage(input, pls).asString();
    assertEqualsIgnoreCRLF(getFile("simpleMockedHttpGetWithParams.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)

Example 55 with PipeLineSession

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

the class HttpSenderTest method simpleMockedHttpPost.

@Test
public void simpleMockedHttpPost() throws Throwable {
    // Cannot add headers (aka parameters) for this test!
    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();
    assertEqualsIgnoreCRLF(getFile("simpleMockedHttpPost.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)

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