long timeout = System.currentTimeMillis() + waitTime;
while (!isFileCopied && System.currentTimeMillis() < timeout) {
final SshjSshClient client = getSSHClient(host, privateKey);
Assert.isTrue(file.exists(), "File to be copied to remote machine does not exist");
ByteSource byteSource = com.google.common.io.Files.asByteSource(file);
ByteSourcePayload payload = new ByteSourcePayload(byteSource);
long byteSourceSize = -1;
try {
byteSourceSize = byteSource.size();
payload.getContentMetadata().setContentLength(byteSourceSize);
}
catch (IOException ioe) {
throw new IllegalStateException("Unable to retrieve size for file to be copied to remote machine.", ioe);
}
client.put(uri.getPath(), payload);