@@ -390,6 +390,7 @@ class UtilsSuite extends FunSuite with ResetSystemProperties {
390390 val innerTempDir = Utils .createTempDir(tempDir.getPath)
391391 val tempFile = File .createTempFile(" someprefix" , " somesuffix" , innerTempDir)
392392 val targetDir = new File (" target-dir" )
393+ val testFileDir = new File (" test-filename" )
393394 Files .write(" some text" , tempFile, UTF_8 )
394395
395396 try {
@@ -399,6 +400,8 @@ class UtilsSuite extends FunSuite with ResetSystemProperties {
399400 Utils .fetchHcfsFile(path, targetDir, fs, new SparkConf (), conf, false )
400401 assert(targetDir.exists())
401402 assert(targetDir.isDirectory())
403+ // Testing to make sure it doesn't error if the dir already exists
404+ Utils .fetchHcfsFile(path, targetDir, fs, new SparkConf (), conf, false )
402405 val newInnerDir = new File (targetDir, innerTempDir.getName)
403406 println(" inner temp dir: " + innerTempDir.getName)
404407 targetDir.listFiles().map(_.getName).foreach(println)
@@ -407,9 +410,18 @@ class UtilsSuite extends FunSuite with ResetSystemProperties {
407410 val newInnerFile = new File (newInnerDir, tempFile.getName)
408411 assert(newInnerFile.exists())
409412 assert(newInnerFile.isFile())
413+ val filePath = new Path (" file://" + tempFile.getAbsolutePath)
414+ val testFileName = " testFName"
415+ val testFilefs = Utils .getHadoopFileSystem(filePath.toString, conf)
416+ Utils .fetchHcfsFile(filePath, testFileDir, testFilefs, new SparkConf (),
417+ conf, false , Some (testFileName))
418+ val newFileName = new File (testFileDir, testFileName)
419+ assert(newFileName.exists())
420+ assert(newFileName.isFile())
410421 } finally {
411422 Utils .deleteRecursively(tempDir)
412423 Utils .deleteRecursively(targetDir)
424+ Utils .deleteRecursively(testFileDir)
413425 }
414426 }
415427}
0 commit comments