-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
cc8c93b
commit ce090f1
Showing
7 changed files
with
145 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
core/src/test/java/nl/nn/adapterframework/filesystem/LocalFileSystemActorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package nl.nn.adapterframework.filesystem; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.File; | ||
|
||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
import nl.nn.adapterframework.parameters.Parameter; | ||
import nl.nn.adapterframework.parameters.ParameterList; | ||
import nl.nn.adapterframework.parameters.ParameterValueList; | ||
import nl.nn.adapterframework.stream.Message; | ||
|
||
public class LocalFileSystemActorTest extends FileSystemActorTest<File, LocalFileSystem>{ | ||
|
||
public TemporaryFolder folder; | ||
|
||
|
||
@Override | ||
protected LocalFileSystem createFileSystem() { | ||
LocalFileSystem result=new LocalFileSystem(); | ||
result.setRoot(folder.getRoot().getAbsolutePath()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public void setUp() throws Exception { | ||
folder = new TemporaryFolder(); | ||
folder.create(); | ||
super.setUp(); | ||
} | ||
|
||
@Override | ||
protected IFileSystemTestHelper getFileSystemTestHelper() { | ||
return new LocalFileSystemTestHelper(folder); | ||
} | ||
|
||
|
||
public void fileSystemActorMoveActionTestNoRoot(String destFolder, boolean createDestFolder) throws Exception { | ||
|
||
LocalFileSystem localFileSystemNoRoot=new LocalFileSystem(); | ||
String srcFolder=folder.getRoot().getAbsolutePath(); | ||
|
||
String filename = "sendermove" + FILE1; | ||
String contents = "Tekst om te lezen"; | ||
|
||
if (createDestFolder && destFolder!=null) { | ||
_createFolder(destFolder); | ||
} | ||
createFile(null, filename, contents); | ||
// deleteFile(folder2, filename); | ||
waitForActionToFinish(); | ||
|
||
actor.setAction("move"); | ||
ParameterList params = new ParameterList(); | ||
Parameter p = new Parameter(); | ||
p.setName("destination"); | ||
p.setValue(srcFolder+"/"+destFolder); | ||
params.add(p); | ||
params.configure(); | ||
actor.configure(localFileSystemNoRoot,params,owner); | ||
actor.open(); | ||
|
||
Message message = new Message(srcFolder+"/"+filename); | ||
ParameterValueList pvl= createParameterValueList(params, message, null); | ||
Object result = actor.doAction(message, pvl, null); | ||
|
||
// test | ||
// result should be name of the moved file | ||
assertNotNull("name of moved file should not be null", result); | ||
|
||
// TODO: result should point to new location of file | ||
// TODO: contents of result should be contents of original file | ||
|
||
assertTrue("file should exist in destination folder ["+destFolder+"]", _fileExists(destFolder, filename)); | ||
assertFalse("file should not exist anymore in original folder ["+srcFolder+"]", _fileExists(null, filename)); | ||
} | ||
|
||
|
||
@Test | ||
public void fileSystemActorMoveActionTestRootToFolderNoRoot() throws Exception { | ||
fileSystemActorMoveActionTestNoRoot("folder",true); | ||
} | ||
@Test | ||
public void fileSystemActorMoveActionTestRootToFolderFailIfolderDoesNotExistNoRoot() throws Exception { | ||
thrown.expectMessage("unable to process [move] action for File ["+folder.getRoot().getAbsolutePath()+"/sendermovefile1.txt]: Cannot move file. Destination folder ["+folder.getRoot().getAbsolutePath()+File.separator+"folder] does not exist"); | ||
fileSystemActorMoveActionTestNoRoot("folder",false); | ||
} | ||
@Test | ||
public void fileSystemActorMoveActionTestRootToFolderExistsAndAllowToCreateNoRoot() throws Exception { | ||
fileSystemActorMoveActionTestNoRoot("folder",true); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
core/src/test/java/nl/nn/adapterframework/filesystem/LocalFileSystemSenderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package nl.nn.adapterframework.filesystem; | ||
|
||
import java.io.File; | ||
|
||
import org.junit.rules.TemporaryFolder; | ||
|
||
import nl.nn.adapterframework.senders.LocalFileSystemSender; | ||
|
||
public class LocalFileSystemSenderTest extends FileSystemSenderTest<LocalFileSystemSender, File, LocalFileSystem>{ | ||
|
||
public TemporaryFolder folder; | ||
|
||
@Override | ||
public LocalFileSystemSender createFileSystemSender() { | ||
LocalFileSystemSender result=new LocalFileSystemSender(); | ||
result.setRoot(folder.getRoot().getAbsolutePath()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public void setUp() throws Exception { | ||
folder = new TemporaryFolder(); | ||
folder.create(); | ||
super.setUp(); | ||
} | ||
|
||
@Override | ||
protected IFileSystemTestHelper getFileSystemTestHelper() { | ||
return new LocalFileSystemTestHelper(folder); | ||
} | ||
|
||
} |