17
17
*/
18
18
package org .apache .hadoop .fs .viewfs ;
19
19
20
+ import static org .apache .hadoop .test .LambdaTestUtils .intercept ;
21
+
22
+ import java .io .IOException ;
23
+
20
24
import org .apache .hadoop .conf .Configuration ;
21
25
import org .apache .hadoop .fs .FileSystem ;
22
26
import org .apache .hadoop .fs .FsConstants ;
23
27
import org .apache .hadoop .fs .Path ;
28
+ import org .apache .hadoop .test .AbstractHadoopTestBase ;
24
29
import org .junit .Test ;
25
30
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 {
32
32
33
33
/**
34
34
* Verify that all child file systems of a ViewFileSystem will be shut down
35
35
* when the cache is disabled.
36
36
* @throws IOException
37
37
*/
38
38
@ Test
39
- public void testFileSystemLeak () throws IOException {
39
+ public void testFileSystemLeak () throws Exception {
40
40
41
41
Configuration conf = new Configuration ();
42
42
conf .set ("fs.viewfs.impl" , ViewFileSystem .class .getName ());
@@ -53,12 +53,9 @@ public void testFileSystemLeak() throws IOException {
53
53
viewFs .close ();
54
54
FileSystem .closeAll ();
55
55
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" )));
62
59
}
63
60
}
64
61
}
0 commit comments