下面列出了org.apache.hadoop.fs.swift.util.SwiftTestUtils#touch ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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);
}
/**
* 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);
}
/**
* Asserts that a zero byte file has a status of file and not
* directory or symlink
*
* @throws Exception on failures
*/
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testZeroByteFilesAreDirectories() throws Exception {
Path src = path("/test/testZeroByteFilesAreFiles");
//create a zero byte file
SwiftTestUtils.touch(fs, src);
SwiftTestUtils.assertIsDirectory(fs, src);
}
/**
* Asserts that a zero byte file has a status of file and not
* directory or symlink
*
* @throws Exception on failures
*/
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testZeroByteFilesAreDirectories() throws Exception {
Path src = path("/test/testZeroByteFilesAreFiles");
//create a zero byte file
SwiftTestUtils.touch(fs, src);
SwiftTestUtils.assertIsDirectory(fs, src);
}
/**
* Asserts that a zero byte file has a status of file and not
* file or symlink
*
* @throws Exception on failures
*/
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testZeroByteFilesAreFiles() throws Exception {
Path src = path("/test/testZeroByteFilesAreFiles");
//create a zero byte file
SwiftTestUtils.touch(fs, src);
SwiftTestUtils.assertIsFile(fs, src);
}