Search in sources :

Example 1 with Message

use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.

the class NetStorageSenderTest method rmdirAction.

@Test
public void rmdirAction() throws Throwable {
    NetStorageSender sender = getSender();
    sender.setAction(Action.RMDIR);
    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("rmdirAction.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 2 with Message

use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.

the class NetStorageSenderTest method uploadActionWithSHA256Hash.

@Test
public void uploadActionWithSHA256Hash() throws Throwable {
    NetStorageSender sender = getSender();
    sender.setAction(Action.UPLOAD);
    sender.setHashAlgorithm(HashAlgorithm.SHA256);
    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("uploadActionSHA256.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 3 with Message

use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.

the class NetStorageSenderTest method downloadAction.

@Test
public void downloadAction() throws Throwable {
    NetStorageSender sender = getSender();
    sender.setAction(Action.DOWNLOAD);
    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("downloadAction.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 4 with Message

use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.

the class NetStorageSenderTest method uploadActionWithCustomSHA1Hash.

@Test
public void uploadActionWithCustomSHA1Hash() throws Throwable {
    NetStorageSender sender = getSender();
    sender.setAction(Action.UPLOAD);
    sender.setHashAlgorithm(HashAlgorithm.SHA1);
    Message input = new Message("my/special/path/");
    // Matches response file but uses a different input message
    sender.addParameter(ParameterBuilder.create().withName("sha1").withValue("51e8bbf813bdbcede109d13b863a58132e80b2e2"));
    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("uploadActionSHA1.txt"), result.replace("----", "").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 5 with Message

use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.

the class NetStorageSenderTest method uploadActionWithSHA1Hash.

@Test
public void uploadActionWithSHA1Hash() throws Throwable {
    NetStorageSender sender = getSender();
    sender.setAction(Action.UPLOAD);
    sender.setHashAlgorithm(HashAlgorithm.SHA1);
    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("uploadActionSHA1.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

Message (nl.nn.adapterframework.stream.Message)598 Test (org.junit.Test)385 PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)220 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)114 IOException (java.io.IOException)112 SenderException (nl.nn.adapterframework.core.SenderException)97 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)54 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)54 Parameter (nl.nn.adapterframework.parameters.Parameter)52 PipeForward (nl.nn.adapterframework.core.PipeForward)41 Date (java.util.Date)37 TimeoutException (nl.nn.adapterframework.core.TimeoutException)31 UrlMessage (nl.nn.adapterframework.stream.UrlMessage)31 PipeRunException (nl.nn.adapterframework.core.PipeRunException)30 ByteArrayInputStream (java.io.ByteArrayInputStream)29 InputStream (java.io.InputStream)29 ParameterList (nl.nn.adapterframework.parameters.ParameterList)28 ListenerException (nl.nn.adapterframework.core.ListenerException)27 ParameterException (nl.nn.adapterframework.core.ParameterException)25 SAXException (org.xml.sax.SAXException)19