File bogusFile = File.createTempFile("bogus", "bogus");
final File tmpFile = new File(bogusFile.getParentFile(), "TestJschSftpProtocol");
bogusFile.delete();
tmpFile.mkdirs();
mockc.cd(new ProtocolFile("sshTestDir", true));
File testDownloadFile = new File(tmpFile, "testDownloadFile");
Mockito.doAnswer(new Answer(){
public Object answer(InvocationOnMock invocationOnMock) throws IOException {
PrintWriter writer = new PrintWriter(tmpFile+"/testDownloadFile", "UTF-8");
writer.print(readFile("src/testdata/sshTestDir/sshTestFile"));
writer.close();
return null;
}
}).when(mockc).get(new ProtocolFile("sshTestFile", false), testDownloadFile);
mockc.get(new ProtocolFile("sshTestFile", false), testDownloadFile);
assertTrue(FileUtils.contentEquals(new File("src/testdata/sshTestDir/sshTestFile"), testDownloadFile));
FileUtils.forceDelete(tmpFile);
}