Search in sources :

Example 56 with PipeLineSession

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());
}
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 57 with PipeLineSession

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);
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 58 with PipeLineSession

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);
}
Also used : Message(nl.nn.adapterframework.stream.Message) Parameter(nl.nn.adapterframework.parameters.Parameter) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 59 with PipeLineSession

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());
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 60 with PipeLineSession

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);
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) Message(nl.nn.adapterframework.stream.Message) Node(org.w3c.dom.Node) 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