Skip to content

Commit 6515ee7

Browse files
committed
feedback review.
1 parent e089eff commit 6515ee7

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemClose.java

+10-13
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@
1717
*/
1818
package org.apache.hadoop.fs.viewfs;
1919

20+
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
21+
22+
import java.io.IOException;
23+
2024
import org.apache.hadoop.conf.Configuration;
2125
import org.apache.hadoop.fs.FileSystem;
2226
import org.apache.hadoop.fs.FsConstants;
2327
import org.apache.hadoop.fs.Path;
28+
import org.apache.hadoop.test.AbstractHadoopTestBase;
2429
import org.junit.Test;
2530

26-
import java.io.IOException;
27-
28-
import static org.junit.Assert.assertTrue;
29-
import static org.junit.Assert.fail;
30-
31-
public class TestViewFileSystemClose {
31+
public class TestViewFileSystemClose extends AbstractHadoopTestBase {
3232

3333
/**
3434
* Verify that all child file systems of a ViewFileSystem will be shut down
3535
* when the cache is disabled.
3636
* @throws IOException
3737
*/
3838
@Test
39-
public void testFileSystemLeak() throws IOException {
39+
public void testFileSystemLeak() throws Exception {
4040

4141
Configuration conf = new Configuration();
4242
conf.set("fs.viewfs.impl", ViewFileSystem.class.getName());
@@ -53,12 +53,9 @@ public void testFileSystemLeak() throws IOException {
5353
viewFs.close();
5454
FileSystem.closeAll();
5555
for (FileSystem fs : children) {
56-
try {
57-
fs.create(new Path(rootPath, "neverSuccess"));
58-
fail();
59-
} catch (IOException ioe) {
60-
assertTrue(ioe.getMessage().contains("Filesystem closed"));
61-
}
56+
intercept(IOException.class, "Filesystem closed",
57+
"Expect Filesystem closed IOException",
58+
() -> fs.create(new Path(rootPath, "neverSuccess")));
6259
}
6360
}
6461
}

0 commit comments

Comments
 (0)