*
* @throws Exception
*/
public void testReadWrite() throws Exception {
DFSTestUtil util = new DFSTestUtil("TestFTPFileSystem", 20, 3, 1024 * 1024);
localFs.setWorkingDirectory(workDir);
Path localData = new Path(workDir, "srcData");
Path remoteData = new Path("srcData");
util.createFiles(localFs, localData.toUri().getPath());
boolean dataConsistency = util.checkFiles(localFs, localData.getName());
assertTrue("Test data corrupted", dataConsistency);
// Copy files and directories recursively to FTP file system.
boolean filesCopied = FileUtil.copy(localFs, localData, ftpFs, remoteData,
false, defaultConf);
assertTrue("Copying to FTPFileSystem failed", filesCopied);
// Rename the remote copy
Path renamedData = new Path("Renamed");
boolean renamed = ftpFs.rename(remoteData, renamedData);
assertTrue("Rename failed", renamed);
// Copy files and directories from FTP file system and delete remote copy.
filesCopied = FileUtil.copy(ftpFs, renamedData, localFs, workDir, true,
defaultConf);
assertTrue("Copying from FTPFileSystem fails", filesCopied);
// Check if the data was received completely without any corruption.
dataConsistency = util.checkFiles(localFs, renamedData.getName());
assertTrue("Invalid or corrupted data recieved from FTP Server!",
dataConsistency);
// Delete local copies
boolean deleteSuccess = localFs.delete(renamedData, true)