[Check static addition] Fix TestFileStatus.

Change-Id: I7c583eb61f72f7ba020d8f149c6574110fe9af06
This commit is contained in:
Siyao Meng 2021-08-19 22:47:36 -07:00
parent e724af14b8
commit 6f54c9ecde
1 changed files with 18 additions and 18 deletions

View File

@ -30,12 +30,12 @@ import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.RemoteIterator; import org.apache.hadoop.fs.RemoteIterator;
import org.apache.hadoop.fs.contract.ContractTestUtils;
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus; import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem; import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
import org.apache.hadoop.ipc.RemoteException; import org.apache.hadoop.ipc.RemoteException;
import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.test.GenericTestUtils;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.event.Level; import org.slf4j.event.Level;
@ -44,7 +44,7 @@ import org.slf4j.event.Level;
* This class tests the FileStatus API. * This class tests the FileStatus API.
*/ */
public class TestFileStatus { public class TestFileStatus {
{ static {
GenericTestUtils.setLogLevel(FSNamesystem.LOG, Level.TRACE); GenericTestUtils.setLogLevel(FSNamesystem.LOG, Level.TRACE);
GenericTestUtils.setLogLevel(FileSystem.LOG, Level.TRACE); GenericTestUtils.setLogLevel(FileSystem.LOG, Level.TRACE);
} }
@ -95,11 +95,11 @@ public class TestFileStatus {
Path path = new Path("/"); Path path = new Path("/");
assertTrue( assertTrue(
fs.getFileStatus(path).isDirectory(), "/ should be a directory"); fs.getFileStatus(path).isDirectory(), "/ should be a directory");
Assertions.assertNotErasureCoded(fs, path); ContractTestUtils.assertNotErasureCoded(fs, path);
// Make sure getFileInfo returns null for files which do not exist // Make sure getFileInfo returns null for files which do not exist
HdfsFileStatus fileInfo = dfsClient.getFileInfo("/noSuchFile"); HdfsFileStatus fileInfo = dfsClient.getFileInfo("/noSuchFile");
assertEquals(null, fileInfo, "Non-existant file should result in null"); assertNull(fileInfo, "Non-existant file should result in null");
Path path1 = new Path("/name1"); Path path1 = new Path("/name1");
Path path2 = new Path("/name1/name2"); Path path2 = new Path("/name1/name2");
@ -132,7 +132,7 @@ public class TestFileStatus {
assertEquals(blockSize, status.getBlockSize()); assertEquals(blockSize, status.getBlockSize());
assertEquals(1, status.getReplication()); assertEquals(1, status.getReplication());
assertEquals(fileSize, status.getLen()); assertEquals(fileSize, status.getLen());
Assertions.assertNotErasureCoded(fs, file1); ContractTestUtils.assertNotErasureCoded(fs, file1);
assertEquals(file1.makeQualified(fs.getUri(), assertEquals(file1.makeQualified(fs.getUri(),
fs.getWorkingDirectory()).toString(), fs.getWorkingDirectory()).toString(),
status.getPath().toString()); status.getPath().toString());
@ -151,7 +151,7 @@ public class TestFileStatus {
assertEquals(blockSize, status.getBlockSize()); assertEquals(blockSize, status.getBlockSize());
assertEquals(1, status.getReplication()); assertEquals(1, status.getReplication());
assertEquals(fileSize, status.getLen()); assertEquals(fileSize, status.getLen());
Assertions.assertNotErasureCoded(fs, file1); ContractTestUtils.assertNotErasureCoded(fs, file1);
assertEquals(file1.makeQualified(fs.getUri(), assertEquals(file1.makeQualified(fs.getUri(),
fs.getWorkingDirectory()).toString(), fs.getWorkingDirectory()).toString(),
status.getPath().toString()); status.getPath().toString());
@ -199,8 +199,8 @@ public class TestFileStatus {
// test getFileStatus on an empty directory // test getFileStatus on an empty directory
FileStatus status = fs.getFileStatus(dir); FileStatus status = fs.getFileStatus(dir);
assertTrue(status.isDirectory(), dir + " should be a directory"); assertTrue(status.isDirectory(), dir + " should be a directory");
assertTrue(status.getLen() == 0, dir + " should be zero size "); assertEquals(0, status.getLen(), dir + " should be zero size ");
Assertions.assertNotErasureCoded(fs, dir); ContractTestUtils.assertNotErasureCoded(fs, dir);
assertEquals(dir.makeQualified(fs.getUri(), assertEquals(dir.makeQualified(fs.getUri(),
fs.getWorkingDirectory()).toString(), fs.getWorkingDirectory()).toString(),
status.getPath().toString()); status.getPath().toString());
@ -322,7 +322,7 @@ public class TestFileStatus {
try { try {
itor.hasNext(); itor.hasNext();
fail("FileNotFoundException expected"); fail("FileNotFoundException expected");
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException ignored) {
} }
fs.mkdirs(file2); fs.mkdirs(file2);
@ -337,7 +337,7 @@ public class TestFileStatus {
count++; count++;
} }
fail("FileNotFoundException expected"); fail("FileNotFoundException expected");
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException ignored) {
} }
assertEquals(2, count); assertEquals(2, count);
} }