public static void copyFileToRemote(String privateKey, String host, URI uri,
			File file, long waitTime)
	{
		Assert.hasText(privateKey, "privateKey must not be empty nor null.");
		Assert.hasText(host, "The remote machine's URL must be specified.");
		Assert.notNull(uri, "uri should not be null");
		Assert.notNull(file, "file must not be null");
		boolean isFileCopied = false;
		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);
			if (client.exec("ls -al " + uri.getPath()).getExitStatus() == 0) {
				ExecResponse statResponse = client.exec("stat --format=%s " + uri.getPath());
				long copySize = Long.valueOf(statResponse.getOutput().trim());
				if (copySize == byteSourceSize) {
					isFileCopied = true;
				}
			}
		}

	}
Copy a file from test machine to remote machine.

@param privateKey The ssh private key for the remote container
@param host The remote machine's ip.
@param uri to the location where the file will be copied to remote machine.
@param file The file to migrate to remote machine.
spring-xd-integration-test/src/main/java/org/springframework/xd/integration/util/StreamUtils.java