|
@@ -19,10 +19,14 @@
|
|
|
package org.apache.hadoop.fs.contract;
|
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
+import java.io.IOException;
|
|
|
|
|
|
import org.apache.hadoop.fs.FileStatus;
|
|
|
+import org.apache.hadoop.fs.FileSystem;
|
|
|
import org.apache.hadoop.fs.Path;
|
|
|
import org.junit.Test;
|
|
|
+import static org.junit.Assert.assertEquals;
|
|
|
+import static org.junit.Assert.assertTrue;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
@@ -58,4 +62,23 @@ public abstract class AbstractContractGetFileStatusTest extends
|
|
|
handleExpectedException(e);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testListStatusEmptyDirectory() throws IOException {
|
|
|
+ // remove the test directory
|
|
|
+ FileSystem fs = getFileSystem();
|
|
|
+ assertTrue(fs.delete(getContract().getTestPath(), true));
|
|
|
+
|
|
|
+ // create a - non-qualified - Path for a subdir
|
|
|
+ Path subfolder = getContract().getTestPath().suffix("/"+testPath.getName());
|
|
|
+ assertTrue(fs.mkdirs(subfolder));
|
|
|
+
|
|
|
+ // assert empty ls on the empty dir
|
|
|
+ assertEquals("ls on an empty directory not of length 0", 0,
|
|
|
+ fs.listStatus(subfolder).length);
|
|
|
+
|
|
|
+ // assert non-empty ls on parent dir
|
|
|
+ assertTrue("ls on a non-empty directory of length 0",
|
|
|
+ fs.listStatus(getContract().getTestPath()).length > 0);
|
|
|
+ }
|
|
|
}
|