use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class HttpSenderTest method simpleMockedHttpPostJSON.
@Test
public void simpleMockedHttpPostJSON() throws Throwable {
sender = getSender();
Message input = new Message("{\"key\": \"value\"}");
PipeLineSession pls = new PipeLineSession(session);
sender.setMethodType(HttpMethod.POST);
sender.setContentType("application/json");
sender.configure();
sender.open();
String result = sender.sendMessage(input, pls).asString();
assertEqualsIgnoreCRLF(getFile("simpleMockedHttpPostJSON.txt"), result);
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class HttpSenderResultTest method simpleMultiPartResponseMockedHttpGet.
@Test
public void simpleMultiPartResponseMockedHttpGet() throws Exception {
HttpSender sender = createHttpSenderFromFile("multipart1.txt");
PipeLineSession pls = new PipeLineSession();
sender.setMethodType(HttpMethod.GET);
sender.setMultipartResponse(true);
sender.configure();
sender.open();
String result = sender.sendMessage(new Message("tralala"), pls).asString();
assertEquals("text default", result);
int multipartAttachmentCount = 0;
for (Map.Entry<String, Object> entry : pls.entrySet()) {
System.out.println("found multipart [" + entry.getKey() + "]");
multipartAttachmentCount++;
}
assertEquals(2, multipartAttachmentCount);
InputStream multipart1 = pls.getMessage("multipart1").asInputStream();
assertEquals("Content of a txt file.", Misc.streamToString(multipart1).trim());
InputStream multipart2 = pls.getMessage("multipart2").asInputStream();
assertEquals("<!DOCTYPE html><title>Content of a html file.</title>", Misc.streamToString(multipart2).trim());
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class HttpSenderResultTest method simpleBase64MockedHttpGet.
@Test
public void simpleBase64MockedHttpGet() throws Exception {
HttpSender sender = createHttpSender();
PipeLineSession session = new PipeLineSession();
sender.setMethodType(HttpMethod.GET);
sender.setBase64(true);
sender.configure();
sender.open();
// Use InputStream 'content' as result.
String result = sender.sendMessage(new Message(""), session).asString();
assertEquals("PGR1bW15IHJlc3VsdC8+", result.trim());
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class HttpSenderTest method simpleMockedHttpPut.
@Test
public void simpleMockedHttpPut() throws Throwable {
// Cannot add headers (aka parameters) for this test!
sender = getSender(false);
Message input = new Message("hallo");
PipeLineSession pls = new PipeLineSession(session);
// should handle a mix of upper and lowercase characters :)
sender.setMethodType(HttpMethod.PUT);
sender.configure();
sender.open();
String result = sender.sendMessage(input, pls).asString();
assertEqualsIgnoreCRLF(getFile("simpleMockedHttpPut.txt"), result.trim());
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class HttpSenderTest method postTypeMtom.
@Test
public void postTypeMtom() throws Throwable {
sender = getSender();
Message input = new Message("<xml>input</xml>");
PipeLineSession pls = new PipeLineSession(session);
sender.setMethodType(HttpMethod.POST);
sender.setPostType(PostType.MTOM);
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("simpleMockedHttpMtom.txt"), result.trim());
}
Aggregations