Skip to content

Commit fb86f0d

Browse files
author
Vikram Agrawal
committed
Minor Fixes in FileUtilitySuite
1 parent fcf2a86 commit fb86f0d

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

core/src/test/java/org/apache/spark/io/FileUtilitySuite.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,20 @@
3333
public class FileUtilitySuite {
3434

3535
protected File sourceFolder;
36-
protected File destFile;
3736
protected File destTarLoc;
37+
protected File destFolder;
3838

3939
@Before
4040
public void setUp() throws IOException {
41-
sourceFolder = Utils.createTempDir(System.getProperty("java.io.tmpdir"),
42-
"FileUtilTest" + RandomUtils.nextLong());
43-
destTarLoc = File.createTempFile("dest-tar", ".tar");
44-
destFile = File.createTempFile("dest-file", ".tmp");
41+
String tmpDir = System.getProperty("java.io.tmpdir");
42+
sourceFolder = Utils.createTempDir(tmpDir, "FileUtilTest-src-" + RandomUtils.nextLong());
43+
destFolder = Utils.createTempDir(tmpDir, "FileUtilTest-dest-" + RandomUtils.nextLong());
44+
destTarLoc= File.createTempFile("dest-tar", ".tar");
4545
}
4646

4747
@After
4848
public void tearDown() {
4949
destTarLoc.delete();
50-
destFile.delete();
5150
}
5251

5352
@Test
@@ -66,14 +65,12 @@ public void testCreationAndExtraction() throws IllegalStateException, IOExceptio
6665
Assert.assertTrue(destTarLoc.exists());
6766

6867
// Extract the tarball
69-
String destFilePath = destFile.getAbsolutePath();
70-
destFile.delete();
71-
Assert.assertFalse(destFile.exists());
72-
FileUtility.extractTarFile(destTarLoc.getAbsolutePath(), destFilePath);
68+
Assert.assertEquals(destFolder.listFiles().length , 0);
69+
FileUtility.extractTarFile(destTarLoc.getAbsolutePath(), destFolder.getAbsolutePath());
7370

74-
Assert.assertTrue(destFile.exists());
75-
Assert.assertEquals(destFile.listFiles().length , 1);
76-
Assert.assertArrayEquals(randomBytes, FileUtils.readFileToByteArray(destFile.listFiles()[0]));
71+
Assert.assertTrue(destFolder.exists());
72+
Assert.assertEquals(destFolder.listFiles().length , 1);
73+
Assert.assertArrayEquals(randomBytes, FileUtils.readFileToByteArray(destFolder.listFiles()[0]));
7774
}
7875

7976
}

0 commit comments

Comments
 (0)