use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class HttpSenderTest method simpleMockedHttpMtom.
@Test
public void simpleMockedHttpMtom() throws Throwable {
sender = getSender();
Message input = new Message("<xml>input</xml>");
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("simpleMockedHttpMtom.txt"), result.trim());
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class FileSystemSenderTest method fileSystemSenderRmdirActionTest.
@Test
public void fileSystemSenderRmdirActionTest() throws Exception {
String folder = DIR1;
if (!_folderExists(DIR1)) {
_createFolder(folder);
}
fileSystemSender.setAction(FileSystemAction.RMDIR);
fileSystemSender.configure();
fileSystemSender.open();
PipeLineSession session = new PipeLineSession();
Message message = new Message(folder);
Message result = fileSystemSender.sendMessage(message, session);
// test
assertEquals("result of sender should be name of deleted folder", folder, result.asString());
waitForActionToFinish();
boolean actual = _folderExists(folder);
// test
assertFalse("Expected folder [" + folder + "] " + "not to be present", actual);
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class FileSystemSenderTest method fileSystemSenderRenameActionTest.
@Test
public void fileSystemSenderRenameActionTest() throws Exception {
String filename = "toberenamed" + FILE1;
String dest = "renamed" + FILE1;
if (!_fileExists(filename)) {
createFile(null, filename, "is not empty");
}
fileSystemSender.addParameter(new Parameter("destination", dest));
fileSystemSender.setAction(FileSystemAction.RENAME);
fileSystemSender.configure();
fileSystemSender.open();
deleteFile(null, dest);
PipeLineSession session = new PipeLineSession();
Message message = new Message(filename);
Message result = fileSystemSender.sendMessage(message, session);
// test
assertEquals("result of sender should be new name of file", dest, result.asString());
boolean actual = _fileExists(filename);
// test
assertFalse("Expected file [" + filename + "] " + "not to be present", actual);
actual = _fileExists(dest);
// test
assertTrue("Expected file [" + dest + "] " + "to be present", actual);
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class FileSystemSenderTest method fileSystemSenderDownloadActionBase64Test.
@Test
public void fileSystemSenderDownloadActionBase64Test() throws Exception {
String filename = "sender" + FILE1;
String contents = "Tekst om te lezen";
createFile(null, filename, contents);
waitForActionToFinish();
fileSystemSender.setAction(FileSystemAction.DOWNLOAD);
fileSystemSender.configure();
fileSystemSender.setBase64(Base64Pipe.Direction.ENCODE);
fileSystemSender.open();
PipeLineSession session = new PipeLineSession();
Message message = new Message(filename);
Message result = fileSystemSender.sendMessage(message, session);
String contentsBase64 = Base64.encodeBase64String(contents.getBytes());
// test
assertEquals("result should be base64 of file content", contentsBase64.trim(), result.asString().trim());
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class ParameterTest method testParameterFromNodeToNode.
@Test
public void testParameterFromNodeToNode() throws Exception {
Node node = XmlUtils.buildDomDocument("<someValue/>").getFirstChild();
String expectedResultContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><someValue/>";
PipeLineSession session = new PipeLineSession();
session.put("originalMessage", node);
Parameter parameter = new Parameter();
parameter.setName("InputMessage");
parameter.setSessionKey("originalMessage");
parameter.setType(ParameterType.NODE);
parameter.configure();
ParameterValueList alreadyResolvedParameters = new ParameterValueList();
Message message = new Message("fakeMessage");
Object result = parameter.getValue(alreadyResolvedParameters, message, session, true);
assertThat(result, instanceOf(Node.class));
assertThat(result, not(instanceOf(Document.class)));
String contents = XmlUtils.transformXml(TransformerFactory.newInstance().newTransformer(), new DOMSource((Node) result));
assertEquals(expectedResultContents, contents);
}
Aggregations