Search in sources :

Example 6 with PipeLineSession

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

the class NetStorageSenderTest method renameAction.

@Test
public void renameAction() throws Throwable {
    NetStorageSender sender = getSender();
    sender.setAction(Action.RENAME);
    Message input = new Message("my/special/path/file1.txt");
    sender.addParameter(new Parameter("destination", "my/other/special/path/file2.txt"));
    try {
        PipeLineSession pls = new PipeLineSession(session);
        sender.configure();
        sender.open();
        String result = sender.sendMessage(input, pls).asString();
        assertEqualsIgnoreCRLF(getFile("renameAction.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    } finally {
        if (sender != null) {
            sender.close();
        }
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) Parameter(nl.nn.adapterframework.parameters.Parameter) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SenderException(nl.nn.adapterframework.core.SenderException) Test(org.junit.Test)

Example 7 with PipeLineSession

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

the class NetStorageSenderTest method uploadActionWithMD5Hash.

@Test
public void uploadActionWithMD5Hash() throws Throwable {
    NetStorageSender sender = getSender();
    sender.setAction(Action.UPLOAD);
    sender.setHashAlgorithm(HashAlgorithm.MD5);
    Message input = new Message("my/special/path/");
    sender.addParameter(ParameterBuilder.create().withName("file").withSessionKey("fileMessage"));
    try {
        Message file = new Message("<dummyFile>");
        PipeLineSession pls = new PipeLineSession(session);
        pls.put("fileMessage", file);
        sender.configure();
        sender.open();
        String result = sender.sendMessage(input, pls).asString();
        assertEqualsIgnoreCRLF(getFile("uploadActionMD5.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    } finally {
        if (sender != null) {
            sender.close();
        }
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SenderException(nl.nn.adapterframework.core.SenderException) Test(org.junit.Test)

Example 8 with PipeLineSession

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

the class NetStorageSenderTest method dirAction.

@Test
public void dirAction() throws Throwable {
    NetStorageSender sender = getSender();
    sender.setAction(Action.DIR);
    Message input = new Message("my/special/path/");
    try {
        PipeLineSession pls = new PipeLineSession(session);
        sender.configure();
        sender.open();
        String result = sender.sendMessage(input, pls).asString();
        assertEqualsIgnoreCRLF(getFile("dirAction.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    } finally {
        if (sender != null) {
            sender.close();
        }
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SenderException(nl.nn.adapterframework.core.SenderException) Test(org.junit.Test)

Example 9 with PipeLineSession

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

the class NetStorageSenderTest method uploadAction.

@Test
public void uploadAction() throws Throwable {
    NetStorageSender sender = getSender();
    sender.setAction(Action.UPLOAD);
    Message input = new Message("my/special/path/");
    sender.addParameter(ParameterBuilder.create().withName("file").withSessionKey("fileMessage"));
    try {
        Message file = new Message("<dummyFile>");
        PipeLineSession pls = new PipeLineSession(session);
        pls.put("fileMessage", file);
        sender.configure();
        sender.open();
        String result = sender.sendMessage(input, pls).asString();
        assertEqualsIgnoreCRLF(getFile("uploadAction.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    } finally {
        if (sender != null) {
            sender.close();
        }
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SenderException(nl.nn.adapterframework.core.SenderException) Test(org.junit.Test)

Example 10 with PipeLineSession

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

the class NetStorageSenderTest method duActionWithRootDir.

@Test
public void duActionWithRootDir() throws Throwable {
    NetStorageSender sender = getSender();
    sender.setAction(Action.DU);
    // Start and end with a slash!
    sender.setRootDir("/my/special/");
    // Last slash should be removed!
    Message input = new Message("path/");
    try {
        PipeLineSession pls = new PipeLineSession(session);
        sender.configure();
        sender.open();
        String result = sender.sendMessage(input, pls).asString();
        assertEqualsIgnoreCRLF(getFile("duAction.txt"), result.trim());
    } catch (SenderException e) {
        throw e.getCause();
    } finally {
        if (sender != null) {
            sender.close();
        }
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) SenderException(nl.nn.adapterframework.core.SenderException) 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