Search in sources :

Example 1 with SwiftFileStatus

use of org.apache.hadoop.fs.swift.snative.SwiftFileStatus in project hadoop by apache.

the class TestSwiftFileSystemDirectories method testDirectoriesOffRootHaveMatchingFileStatus.

/**
   * test that a dir off root has a listStatus() call that
   * works as expected. and that when a child is added. it changes
   *
   * @throws Exception on failures
   */
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testDirectoriesOffRootHaveMatchingFileStatus() throws Exception {
    Path test = path("/test");
    fs.delete(test, true);
    mkdirs(test);
    assertExists("created test directory", test);
    FileStatus[] statuses = fs.listStatus(test);
    String statusString = statusToString(test.toString(), statuses);
    assertEquals("Wrong number of elements in file status " + statusString, 0, statuses.length);
    Path src = path("/test/file");
    //create a zero byte file
    SwiftTestUtils.touch(fs, src);
    //stat it
    statuses = fs.listStatus(test);
    statusString = statusToString(test.toString(), statuses);
    assertEquals("Wrong number of elements in file status " + statusString, 1, statuses.length);
    SwiftFileStatus stat = (SwiftFileStatus) statuses[0];
    assertTrue("isDir(): Not a directory: " + stat, stat.isDir());
    extraStatusAssertions(stat);
}
Also used : Path(org.apache.hadoop.fs.Path) SwiftFileStatus(org.apache.hadoop.fs.swift.snative.SwiftFileStatus) SwiftFileStatus(org.apache.hadoop.fs.swift.snative.SwiftFileStatus) FileStatus(org.apache.hadoop.fs.FileStatus) Test(org.junit.Test)

Aggregations

FileStatus (org.apache.hadoop.fs.FileStatus)1 Path (org.apache.hadoop.fs.Path)1 SwiftFileStatus (org.apache.hadoop.fs.swift.snative.SwiftFileStatus)1 Test (org.junit.Test)1