@Test public void copyFromRemoteToRemote() throws IOException { RemoteSecureCopyInputs remoteSecureCopyInputs = getRemoteSecureCopyInputs(); scpCopier = new SCPCopier(remoteSecureCopyInputs) { protected void establishKnownHostsConfiguration(KnownHostsFile knownHostsFile, JSch jsch, Session session) throws JSchException, IOException { } protected void establishPrivateKeyFile(KeyFile keyFile, JSch jsch, Session session, boolean usesSrcPrivateKeyFile) { } protected boolean copyFromLocalToRemote(String srcPath, String destPath) { return true; } protected boolean copyFromRemoteToLocal(String srcPath, String destPath) { return true; } }; mockStatic(File.class); when(File.createTempFile(anyString(), anyString())).thenReturn(tempFileMock); when(tempFileMock.getCanonicalPath()).thenReturn("C:\\myTestFolder"); boolean isCopied = scpCopier.copyFromRemoteToRemote(); verify(tempFileMock).delete(); assertEquals(true, isCopied); }
public boolean copyFromRemoteToRemote() throws IOException { File temporaryDestFile = File.createTempFile("SCPCopy", ".tmp"); String temporaryDestFilePath = temporaryDestFile.getCanonicalPath().replace("\\", "\\\\"); boolean result = copyFromRemoteToLocal(remoteSecureCopyInputs.getSrcPath(), temporaryDestFilePath) && copyFromLocalToRemote(temporaryDestFilePath, remoteSecureCopyInputs.getDestPath()); temporaryDestFile.delete(); return result; }
SCPCopier { public boolean copyFromRemoteToRemote() throws IOException { File temporaryDestFile = File.createTempFile("SCPCopy", ".tmp"); String temporaryDestFilePath = temporaryDestFile.getCanonicalPath().replace("\\", "\\\\"); boolean result = copyFromRemoteToLocal(remoteSecureCopyInputs.getSrcPath(), temporaryDestFilePath) && copyFromLocalToRemote(temporaryDestFilePath, remoteSecureCopyInputs.getDestPath()); temporaryDestFile.delete(); return result; } }
SCPCopier { public boolean copyFromRemoteToRemote() throws IOException { File temporaryDestFile = File.createTempFile("SCPCopy", ".tmp"); String temporaryDestFilePath = temporaryDestFile.getCanonicalPath().replace("\\", "\\\\"); boolean result = copyFromRemoteToLocal(remoteSecureCopyInputs.getSrcPath(), temporaryDestFilePath) && copyFromLocalToRemote(temporaryDestFilePath, remoteSecureCopyInputs.getDestPath()); temporaryDestFile.delete(); return result; } SCPCopier(RemoteSecureCopyInputs remoteSecureCopyInputs); }
SCPCopier { public boolean copyFromRemoteToRemote() throws IOException { File temporaryDestFile = File.createTempFile("SCPCopy", ".tmp"); String temporaryDestFilePath = temporaryDestFile.getCanonicalPath().replace("\\", "\\\\"); boolean result = copyFromRemoteToLocal(remoteSecureCopyInputs.getSrcPath(), temporaryDestFilePath) && copyFromLocalToRemote(temporaryDestFilePath, remoteSecureCopyInputs.getDestPath()); temporaryDestFile.delete(); return result; } SCPCopier(RemoteSecureCopyInputs remoteSecureCopyInputs); boolean copyFromRemoteToRemote(); boolean copyFromLocalToRemote(); boolean copyFromRemoteToLocal(); }
SCPCopier { public boolean copyFromRemoteToRemote() throws IOException { File temporaryDestFile = File.createTempFile("SCPCopy", ".tmp"); String temporaryDestFilePath = temporaryDestFile.getCanonicalPath().replace("\\", "\\\\"); boolean result = copyFromRemoteToLocal(remoteSecureCopyInputs.getSrcPath(), temporaryDestFilePath) && copyFromLocalToRemote(temporaryDestFilePath, remoteSecureCopyInputs.getDestPath()); temporaryDestFile.delete(); return result; } SCPCopier(RemoteSecureCopyInputs remoteSecureCopyInputs); boolean copyFromRemoteToRemote(); boolean copyFromLocalToRemote(); boolean copyFromRemoteToLocal();  }