Search in sources :

Example 21 with MessageOutputStream

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

the class FileSystemSenderTest method fileSystemSenderUploadActionTestWithOutputStream.

@Test
public void fileSystemSenderUploadActionTestWithOutputStream() throws Exception {
    String filename = "uploadedwithInputStream" + FILE1;
    String contents = "Some text content to test upload action\n";
    if (_fileExists(filename)) {
        _deleteFile(null, filename);
    }
    PipeLineSession session = new PipeLineSession();
    fileSystemSender.addParameter(new Parameter("filename", filename));
    fileSystemSender.setAction(FileSystemAction.UPLOAD);
    fileSystemSender.configure();
    fileSystemSender.open();
    // assertTrue(fileSystemSender.canProvideOutputStream());
    MessageOutputStream target = fileSystemSender.provideOutputStream(session, null);
    assertNotNull(target);
    // stream the contents
    try (Writer writer = target.asWriter()) {
        writer.write(contents);
    }
    // verify the filename is properly returned
    String stringResult = target.getPipeRunResult().getResult().asString();
    TestAssertions.assertXpathValueEquals(filename, stringResult, "file/@name");
    // verify the file contents
    waitForActionToFinish();
    String actualContents = readFile(null, filename);
    assertEquals(contents, actualContents);
}
Also used : MessageOutputStream(nl.nn.adapterframework.stream.MessageOutputStream) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Parameter(nl.nn.adapterframework.parameters.Parameter) Writer(java.io.Writer) Test(org.junit.Test)

Aggregations

MessageOutputStream (nl.nn.adapterframework.stream.MessageOutputStream)21 StreamingException (nl.nn.adapterframework.stream.StreamingException)9 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)7 ContentHandler (org.xml.sax.ContentHandler)6 IOException (java.io.IOException)5 Writer (java.io.Writer)5 ParameterException (nl.nn.adapterframework.core.ParameterException)5 SenderException (nl.nn.adapterframework.core.SenderException)5 Message (nl.nn.adapterframework.stream.Message)5 OutputStream (java.io.OutputStream)4 PipeRunException (nl.nn.adapterframework.core.PipeRunException)4 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)4 TimeoutException (nl.nn.adapterframework.core.TimeoutException)4 ThreadConnector (nl.nn.adapterframework.stream.ThreadConnector)4 SAXException (org.xml.sax.SAXException)4 PipeForward (nl.nn.adapterframework.core.PipeForward)3 PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)3 Parameter (nl.nn.adapterframework.parameters.Parameter)3 Test (org.junit.Test)3 SQLException (java.sql.SQLException)2