@Test(timeout = 30000) public void testStat2Paths1() { assertNull(FileUtil.stat2Paths(null)); FileStatus[] fileStatuses = new FileStatus[0]; Path[] paths = FileUtil.stat2Paths(fileStatuses); assertEquals(0, paths.length); Path path1 = new Path("file://foo"); Path path2 = new Path("file://moo"); fileStatuses = new FileStatus[] { new FileStatus(3, false, 0, 0, 0, path1), new FileStatus(3, false, 0, 0, 0, path2) }; paths = FileUtil.stat2Paths(fileStatuses); assertEquals(2, paths.length); assertEquals(paths[0], path1); assertEquals(paths[1], path2); }
@Test(timeout = 30000) public void testStat2Paths2() { Path defaultPath = new Path("file://default"); Path[] paths = FileUtil.stat2Paths(null, defaultPath); assertEquals(1, paths.length); assertEquals(defaultPath, paths[0]); paths = FileUtil.stat2Paths(null, null); assertTrue(paths != null); assertEquals(1, paths.length); assertEquals(null, paths[0]); Path path1 = new Path("file://foo"); Path path2 = new Path("file://moo"); FileStatus[] fileStatuses = new FileStatus[] { new FileStatus(3, false, 0, 0, 0, path1), new FileStatus(3, false, 0, 0, 0, path2) }; paths = FileUtil.stat2Paths(fileStatuses, defaultPath); assertEquals(2, paths.length); assertEquals(paths[0], path1); assertEquals(paths[1], path2); }