下面列出了org.apache.hadoop.fs.swift.util.SwiftTestUtils#writeTextFile ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testBlocksizeNonZeroForFile() throws Throwable {
Path smallfile = new Path("/test/smallfile");
SwiftTestUtils.writeTextFile(fs, smallfile, "blocksize", true);
createFile(smallfile);
FileStatus status = getFs().getFileStatus(smallfile);
assertTrue("Zero blocksize in " + status,
status.getBlockSize() != 0L);
assertTrue("Zero replication in " + status,
status.getReplication() != 0L);
}
/**
* 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 testMultiByteFilesAreFiles() throws Exception {
Path src = path("/test/testMultiByteFilesAreFiles");
SwiftTestUtils.writeTextFile(fs, src, "testMultiByteFilesAreFiles", false);
assertIsFile(src);
FileStatus status = fs.getFileStatus(src);
assertFalse(status.isDir());
}
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testListFilesRootDir() throws Throwable {
Path dir = path("/");
Path child = new Path(dir, "test");
fs.delete(child, true);
SwiftTestUtils.writeTextFile(fs, child, "text", false);
assertListFilesFinds(fs, dir, child, false);
}
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testListFilesSubDir() throws Throwable {
createTestSubdirs();
Path dir = path("/test/subdir");
Path child = new Path(dir, "text.txt");
SwiftTestUtils.writeTextFile(fs, child, "text", false);
assertListFilesFinds(fs, dir, child, false);
}
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testListFilesRecursive() throws Throwable {
createTestSubdirs();
Path dir = path("/test/recursive");
Path child = new Path(dir, "hadoop/a/a.txt");
SwiftTestUtils.writeTextFile(fs, child, "text", false);
assertListFilesFinds(fs, dir, child, true);
}
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testBlocksizeNonZeroForFile() throws Throwable {
Path smallfile = new Path("/test/smallfile");
SwiftTestUtils.writeTextFile(fs, smallfile, "blocksize", true);
createFile(smallfile);
FileStatus status = getFs().getFileStatus(smallfile);
assertTrue("Zero blocksize in " + status,
status.getBlockSize() != 0L);
assertTrue("Zero replication in " + status,
status.getReplication() != 0L);
}
/**
* 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 testMultiByteFilesAreFiles() throws Exception {
Path src = path("/test/testMultiByteFilesAreFiles");
SwiftTestUtils.writeTextFile(fs, src, "testMultiByteFilesAreFiles", false);
assertIsFile(src);
FileStatus status = fs.getFileStatus(src);
assertFalse(status.isDir());
}
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testListFilesRootDir() throws Throwable {
Path dir = path("/");
Path child = new Path(dir, "test");
fs.delete(child, true);
SwiftTestUtils.writeTextFile(fs, child, "text", false);
assertListFilesFinds(fs, dir, child, false);
}
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testListFilesSubDir() throws Throwable {
createTestSubdirs();
Path dir = path("/test/subdir");
Path child = new Path(dir, "text.txt");
SwiftTestUtils.writeTextFile(fs, child, "text", false);
assertListFilesFinds(fs, dir, child, false);
}
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testListFilesRecursive() throws Throwable {
createTestSubdirs();
Path dir = path("/test/recursive");
Path child = new Path(dir, "hadoop/a/a.txt");
SwiftTestUtils.writeTextFile(fs, child, "text", false);
assertListFilesFinds(fs, dir, child, true);
}
@Test(timeout = SWIFT_TEST_TIMEOUT)
public void testBlocksizeNonZeroForFile() throws Throwable {
Path smallfile = new Path("/test/smallfile");
SwiftTestUtils.writeTextFile(fs, smallfile, "blocksize", true);
createFile(smallfile);
FileStatus status = getFs().getFileStatus(smallfile);
assertTrue("Zero blocksize in " + status,
status.getBlockSize() != 0L);
assertTrue("Zero replication in " + status,
status.getReplication() != 0L);
}
/**
* 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 testMultiByteFilesAreFiles() throws Exception {
Path src = path("/test/testMultiByteFilesAreFiles");
SwiftTestUtils.writeTextFile(fs, src, "testMultiByteFilesAreFiles", false);
assertIsFile(src);
FileStatus status = fs.getFileStatus(src);
assertFalse(status.isDir());
}