use of nl.nn.adapterframework.core.PipeLineSession 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.core.PipeLineSession 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.core.PipeLineSession in project iaf by ibissource.
the class FileSystemActorTest method fileSystemActorListActionTest.
public void fileSystemActorListActionTest(String inputFolder, int numberOfFiles, int expectedNumberOfFiles) throws Exception {
for (int i = 0; i < numberOfFiles; i++) {
String filename = "tobelisted" + i + FILE1;
if (!_fileExists(filename)) {
createFile(inputFolder, filename, "is not empty");
}
}
actor.setAction(FileSystemAction.LIST);
if (inputFolder != null) {
actor.setInputFolder(inputFolder);
}
actor.configure(fileSystem, null, owner);
actor.open();
Message message = new Message("");
PipeLineSession session = new PipeLineSession();
ParameterValueList pvl = null;
Object result = actor.doAction(message, pvl, session);
String stringResult = (String) result;
log.debug(result);
// TODO test that the fileSystemSender has returned the an XML with the details of the file
// Iterator<F> it = result;
// int count = 0;
// while (it.hasNext()) {
// it.next();
// count++;
// }
String anchor = " count=\"";
int posCount = stringResult.indexOf(anchor);
if (posCount < 0) {
fail("result does not contain anchor [" + anchor + "]");
}
int posQuote = stringResult.indexOf('"', posCount + anchor.length());
int resultCount = Integer.valueOf(stringResult.substring(posCount + anchor.length(), posQuote));
// test
assertEquals("count mismatch", expectedNumberOfFiles, resultCount);
assertEquals("mismatch in number of files", expectedNumberOfFiles, resultCount);
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class FileSystemSenderTest method fileSystemSenderListActionTest.
public void fileSystemSenderListActionTest(String inputFolder, int numberOfFiles) throws Exception {
for (int i = 0; i < numberOfFiles; i++) {
String filename = "tobelisted" + i + FILE1;
if (!_fileExists(filename)) {
createFile(inputFolder, filename, "is not empty");
}
}
fileSystemSender.setAction(FileSystemAction.LIST);
if (inputFolder != null) {
fileSystemSender.setInputFolder(inputFolder);
}
fileSystemSender.configure();
fileSystemSender.open();
PipeLineSession session = new PipeLineSession();
Message message = new Message("");
Message result = fileSystemSender.sendMessage(message, session);
log.debug(result);
// TODO test that the fileSystemSender has returned the an XML with the details of the file
// Iterator<F> it = result;
// int count = 0;
// while (it.hasNext()) {
// it.next();
// count++;
// }
String anchor = " count=\"";
int posCount = result.asString().indexOf(anchor);
if (posCount < 0) {
fail("result does not contain anchor [" + anchor + "]");
}
int posQuote = result.asString().indexOf('"', posCount + anchor.length());
int resultCount = Integer.valueOf(result.asString().substring(posCount + anchor.length(), posQuote));
// test
assertEquals("count mismatch", numberOfFiles, resultCount);
assertEquals("mismatch in number of files", numberOfFiles, resultCount);
}
use of nl.nn.adapterframework.core.PipeLineSession in project iaf by ibissource.
the class FileSystemActorTest method fileSystemActorWriteWithNoCharsetUsed.
@Test
public void fileSystemActorWriteWithNoCharsetUsed() throws Exception {
String filename = "senderwriteWithCharsetUseDefault" + FILE1;
String contents = "€ $ & ^ % @ < é ë ó ú à è";
PipeLineSession session = new PipeLineSession();
session.put("senderwriteWithCharsetUseDefault", contents);
ParameterList params = new ParameterList();
params.add(ParameterBuilder.create().withName("contents").withSessionKey("senderwriteWithCharsetUseDefault"));
params.configure();
waitForActionToFinish();
actor.setAction(FileSystemAction.WRITE);
actor.setFilename(filename);
actor.configure(fileSystem, null, owner);
actor.open();
Message message = new Message(contents);
ParameterValueList pvl = params.getValues(message, session);
actor.doAction(message, pvl, session);
String actualContents = readFile(null, filename);
assertEquals(contents, actualContents);
}
Aggregations