Search in sources :

Example 91 with Message

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());
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 92 with Message

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);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) Message(nl.nn.adapterframework.stream.Message) Test(org.junit.Test)

Example 93 with Message

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);
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) Message(nl.nn.adapterframework.stream.Message) Parameter(nl.nn.adapterframework.parameters.Parameter) Test(org.junit.Test)

Example 94 with Message

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));
}
Also used : ParameterValueList(nl.nn.adapterframework.parameters.ParameterValueList) Message(nl.nn.adapterframework.stream.Message) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Test(org.junit.Test)

Example 95 with Message

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());
}
Also used : ParameterValueList(nl.nn.adapterframework.parameters.ParameterValueList) Message(nl.nn.adapterframework.stream.Message) 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