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);
}
Aggregations