use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.
the class FileSystemPipeTest method fileSystemPipeUploadActionTestWithString.
@Test
public void fileSystemPipeUploadActionTestWithString() throws Exception {
String filename = "uploadedwithString" + FILE1;
String contents = "Some text content to test upload action\n";
if (_fileExists(filename)) {
_deleteFile(null, filename);
}
PipeLineSession session = new PipeLineSession();
session.put("uploadActionTargetwString", contents.getBytes());
fileSystemPipe.addParameter(ParameterBuilder.create().withName("file").withSessionKey("uploadActionTargetwString"));
fileSystemPipe.setAction(FileSystemAction.UPLOAD);
fileSystemPipe.configure();
fileSystemPipe.start();
Message message = new Message(filename);
PipeRunResult prr = fileSystemPipe.doPipe(message, session);
String result = prr.getResult().asString();
waitForActionToFinish();
TestAssertions.assertXpathValueEquals(filename, result, "file/@name");
String actual = readFile(null, filename);
// test
// TODO: evaluate 'result'
// assertEquals("result of sender should be input message",result,message);
assertEquals(contents.trim(), actual.trim());
}
use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.
the class FileSystemPipeTest method fileSystemPipeRmNonEmptyDirActionTest.
@Test
public void fileSystemPipeRmNonEmptyDirActionTest() throws Exception {
String folder = DIR1;
String innerFolder = DIR1 + "/innerFolder";
if (!_folderExists(DIR1)) {
_createFolder(folder);
}
if (!_folderExists(innerFolder)) {
_createFolder(innerFolder);
}
for (int i = 0; i < 3; i++) {
String filename = "file" + i + FILE1;
createFile(folder, filename, "is not empty");
createFile(innerFolder, filename, "is not empty");
}
fileSystemPipe.setRemoveNonEmptyFolder(true);
fileSystemPipe.setAction(FileSystemAction.RMDIR);
fileSystemPipe.configure();
fileSystemPipe.start();
Message message = new Message(folder);
PipeRunResult prr = fileSystemPipe.doPipe(message, null);
String result = prr.getResult().asString();
// test
assertEquals("result of pipe should be name of removed folder", folder, result);
waitForActionToFinish();
boolean actual = _fileExists(folder);
// test
assertFalse("Expected file [" + folder + "] " + "not to be present", actual);
}
use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.
the class FileSystemPipeTest method fileSystemPipeRenameActionTest.
@Test
public void fileSystemPipeRenameActionTest() throws Exception {
String filename = "toberenamed" + FILE1;
String dest = "renamed" + FILE1;
if (!_fileExists(filename)) {
createFile(null, filename, "is not empty");
}
fileSystemPipe.addParameter(new Parameter("destination", dest));
fileSystemPipe.setAction(FileSystemAction.RENAME);
fileSystemPipe.configure();
fileSystemPipe.start();
deleteFile(null, dest);
Message message = new Message(filename);
PipeRunResult prr = fileSystemPipe.doPipe(message, null);
String result = prr.getResult().asString();
// test
assertEquals("result of pipe should be name of new file", dest, result);
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);
}
use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.
the class FileSystemActorTest method migrated_localFileSystemTestListWildcard.
@Test
public void migrated_localFileSystemTestListWildcard() throws Exception {
String filename = "create" + FILE1;
String filename1 = filename + ".bak";
String filename2 = filename + ".xml";
String contents = "regeltje tekst";
actor.setWildCard("*.xml");
actor.setAction(FileSystemAction.LIST);
actor.configure(fileSystem, null, owner);
actor.open();
createFile(null, filename1, contents);
createFile(null, filename2, contents);
waitForActionToFinish();
Message message = new Message("");
PipeLineSession session = new PipeLineSession();
ParameterValueList pvl = null;
Object result = actor.doAction(message, pvl, session);
String stringResult = (String) result;
assertTrue(stringResult.contains(filename2));
assertFalse(stringResult.contains(filename1));
}
use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.
the class FileSystemActorTest method fileSystemActorReadWithCharsetUseIncompatible.
@Test
public void fileSystemActorReadWithCharsetUseIncompatible() throws Exception {
String filename = "sender" + FILE1;
String contents = "€ è";
String expected = "⬠è";
createFile(null, filename, contents);
waitForActionToFinish();
actor.setAction(FileSystemAction.READ);
actor.setFilename(filename);
actor.setCharset("ISO-8859-1");
actor.configure(fileSystem, null, owner);
actor.open();
Message message = new Message(filename);
ParameterValueList pvl = null;
Message result = Message.asMessage(actor.doAction(message, pvl, session));
assertEquals(expected, result.asString());
}
Aggregations