Skip to content

Commit fef812b

Browse files
author
研发中心-郭飞-philipse
committed
fixcomment
1 parent 561b370 commit fef812b

File tree

3 files changed

+6
-43
lines changed

3 files changed

+6
-43
lines changed

hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRequestHedgingProxyProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import org.apache.hadoop.ipc.StandbyException;
3838
import org.apache.hadoop.security.UserGroupInformation;
3939
import org.apache.hadoop.test.GenericTestUtils;
40-
import org.apache.hadoop.test.LambdaTestUtils;
40+
`import org.apache.hadoop.test.LambdaTestUtils;`
4141
import org.apache.hadoop.util.Lists;
4242
import org.apache.hadoop.util.Time;
4343
import org.junit.Assert;

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSPermission.java

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
import java.util.Map;
3131
import java.util.Random;
3232

33-
import org.apache.hadoop.test.GenericTestUtils;
3433
import org.slf4j.Logger;
3534
import org.slf4j.LoggerFactory;
35+
import org.apache.hadoop.test.LambdaTestUtils;
3636
import org.apache.hadoop.conf.Configuration;
3737
import org.apache.hadoop.fs.CommonConfigurationKeys;
3838
import org.apache.hadoop.fs.FSDataInputStream;
@@ -262,30 +262,13 @@ private void createAndCheckPermission(OpType op, Path name, short umask,
262262
}
263263

264264
@Test
265-
public void testFSNamesystemCheckAccess() throws Exception {
266-
Path testValidDir = new Path("/test1");
267-
Path testValidFile = new Path("/test1/file1");
265+
public void testFSNamesystemCheckAccess(){
268266
Path testInvalidPath = new Path("/test2");
269267
fs = FileSystem.get(conf);
270268

271-
fs.mkdirs(testValidDir);
272-
fs.create(testValidFile);
273-
274-
fs.access(testValidDir, FsAction.READ);
275-
fs.access(testValidFile, FsAction.READ);
276-
277-
assertTrue(fs.exists(testValidDir));
278-
assertTrue(fs.exists(testValidFile));
279-
280-
try {
281-
fs.access(testInvalidPath, FsAction.READ);
282-
fail("Failed to get expected FileNotFoundException");
283-
} catch (FileNotFoundException e) {
284-
GenericTestUtils.assertExceptionContains(
285-
"Path not found: " + testInvalidPath, e);
286-
} finally {
287-
fs.delete(testValidDir, true);
288-
}
269+
LambdaTestUtils.intercept(FileNotFoundException.class,
270+
"Path not found: " + testInvalidPath,
271+
() -> fs.access(testInvalidPath, FsAction.READ));
289272
}
290273

291274
/* Check if the permission of a file/directory is the same as the

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import static org.junit.Assert.*;
2727

2828
import java.io.File;
29-
import java.io.FileNotFoundException;
3029
import java.io.IOException;
3130
import java.net.InetAddress;
3231
import java.net.URI;
@@ -35,7 +34,6 @@
3534
import org.apache.hadoop.conf.Configuration;
3635
import org.apache.hadoop.fs.FileStatus;
3736
import org.apache.hadoop.fs.FileUtil;
38-
import org.apache.hadoop.fs.permission.FsAction;
3937
import org.apache.hadoop.ha.HAServiceProtocol;
4038
import org.apache.hadoop.hdfs.DFSConfigKeys;
4139
import org.apache.hadoop.hdfs.DFSTestUtil;
@@ -48,7 +46,6 @@
4846
import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
4947
import org.apache.hadoop.hdfs.server.namenode.top.TopAuditLogger;
5048
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
51-
import org.apache.hadoop.test.GenericTestUtils;
5249
import org.apache.hadoop.test.Whitebox;
5350
import org.junit.After;
5451
import org.junit.Test;
@@ -123,23 +120,6 @@ public void testStartupSafemode() throws IOException {
123120
+ "isInSafeMode still returned false", fsn.isInSafeMode());
124121
}
125122

126-
@Test
127-
public void testCheckAccess() throws IOException {
128-
Configuration conf = new Configuration();
129-
FSImage fsImage = Mockito.mock(FSImage.class);
130-
FSEditLog fsEditLog = Mockito.mock(FSEditLog.class);
131-
Mockito.when(fsImage.getEditLog()).thenReturn(fsEditLog);
132-
String src = "/test1";
133-
FSNamesystem fsn = new FSNamesystem(conf, fsImage);
134-
try {
135-
fsn.checkAccess(src, FsAction.READ);
136-
fail("Failed to get expected FileNotFoundException");
137-
} catch (FileNotFoundException e) {
138-
GenericTestUtils.assertExceptionContains(
139-
"Path not found: " + src, e);
140-
}
141-
}
142-
143123
@Test
144124
public void testReplQueuesActiveAfterStartupSafemode() throws IOException, InterruptedException{
145125
Configuration conf = new Configuration();

0 commit comments

Comments
 (0)