FileSystemOperations { public Path uploadToRemoteFile(Path stagingDir, String fileToUpload) throws IOException { FileSystem fs = remoteDirectoryManager.getDefaultFileSystem(); File localFile = new File(fileToUpload); if (!localFile.exists()) { throw new FileNotFoundException( "Trying to upload file " + localFile.getAbsolutePath() + " to remote, but could not find local file!"); } String filename = localFile.getName(); Path uploadedFilePath = new Path(stagingDir, filename); if (!uploadedFiles.contains(uploadedFilePath)) { if (SubmarineLogs.isVerbose()) { LOG.info("Copying local file " + fileToUpload + " to remote " + uploadedFilePath); } fs.copyFromLocalFile(new Path(fileToUpload), uploadedFilePath); uploadedFiles.add(uploadedFilePath); } return uploadedFilePath; } FileSystemOperations(ClientContext clientContext); String downloadAndZip(String remoteDir, String destFileName); String download(String remoteDir, String zipFileName); void deleteFiles(String localUri); @VisibleForTesting void uploadToRemoteFileAndLocalizeToContainerWorkDir(Path stagingDir,
      String fileToUpload, String destFilename, Component comp); Path uploadToRemoteFile(Path stagingDir, String fileToUpload); void validFileSize(String uri); void setPermission(Path destPath, FsPermission permission); static boolean needHdfs(List<String> stringsToCheck); static boolean needHdfs(String content); Set<Path> getUploadedFiles();  }
@Test(expected = FileNotFoundException.class) public void testUploadToRemoteFileNotExistingFile() throws IOException { fileSystemOperations.uploadToRemoteFile(stagingDir, "notExisting"); }
@Test public void testUploadToRemoteFile() throws IOException { File testFile = fileUtils.createFileInTempDir("testFile"); Path path = fileSystemOperations.uploadToRemoteFile(stagingDir, testFile.getAbsolutePath()); File expectedFile = new File(new File(stagingDir.toString()), "testFile"); assertEquals(expectedFile.getAbsolutePath(), path.toString()); Set<Path> uploadedFiles = fileSystemOperations.getUploadedFiles(); assertEquals(1, uploadedFiles.size()); List<Path> pathList = Lists.newArrayList(uploadedFiles); Path storedPath = pathList.get(0); assertEquals(path, storedPath); }