RemoteResourceManager { protected void uploadResource(Resource localResource) throws IOException, SSHClientException { checkNotNull(localResource); long localChecksum = localResource.getResourceChecksum(); if(!localResource.isUploaded() && !isResourceUploadedAndUpToDate(localResource, localChecksum)) { String remoteFile = getRemoteFile(localResource); logger.info("Uploading {} to ssh: new Object[]{localResource, sshClient.getHost(), sshClient.getPort(), remoteFile}); InputStream resourceData = localResource.getResourceData(); sshClient.sftpUpload(resourceData, remoteFile); resourceData.close(); String remoteCrcFile = getRemoteCrcFile(localResource); logger.debug("Uploading CRC checksum {} to ssh: new Object[]{localChecksum, sshClient.getHost(), sshClient.getPort(), remoteCrcFile}); byte[] checksumBytes = String.valueOf(localChecksum). getBytes(Charsets.UTF_8); sshClient.sftpUpload(new ByteArrayInputStream(checksumBytes), remoteCrcFile); } localResource.setUploaded(true); } RemoteResourceManager(SSHClient sshClient, String remoteResourcesDirPath, 
            String remoteResourcesDirName, String remoteSeparator);  RemoteResourceManager(SSHClient sshClient); void addResource(Resource resource); void removeResource(Resource resource); void uploadResources(); void deployResources(); void prepareResourceDirectory(); String getRemoteFile(Resource resource); static final String DEFAULT_REMOTE_RESOURCES_DIR_NAME; static final String DEFAULT_REMOTE_SEPARATOR; }
@Test public void testUploadResource() throws Exception { resourceManager.uploadResource(dummyResource); resourceManager.uploadResource(uploadedUndeployedResource); String dest = String.format("%s%s%s%s%s", RESOURCE_DIR_PATH, SEPARATOR, RESOURCE_DIR_NAME, SEPARATOR, DUMMY_RESOURCE_NAME); verify(sshClient, times(1)).sftpUpload(DUMMY_RESOURCE_DATA, dest); dest = String.format("%s%s%s%s", resourceManager.remoteCrcDir, SEPARATOR, DUMMY_RESOURCE_NAME, RemoteResourceManager.CRC_FILE_EXTENSION); verify(sshClient, times(1)).sftpUpload( Matchers.any(ByteArrayInputStream.class), eq(dest)); }