22 */ |
22 */ |
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @summary Unit test for Files.walkFileTree to test maxDepth parameter |
26 * @summary Unit test for Files.walkFileTree to test maxDepth parameter |
|
27 * @library ../.. |
27 * @compile MaxDepth.java CreateFileTree.java |
28 * @compile MaxDepth.java CreateFileTree.java |
28 * @run main MaxDepth |
29 * @run main MaxDepth |
29 */ |
30 */ |
30 |
31 |
31 import java.nio.file.*; |
32 import java.nio.file.*; |
32 import java.nio.file.attribute.*; |
33 import java.nio.file.attribute.*; |
33 import java.io.IOException; |
34 import java.io.IOException; |
34 import java.util.*; |
35 import java.util.*; |
35 |
36 |
36 public class MaxDepth { |
37 public class MaxDepth { |
37 public static void main(String[] args) throws Exception { |
38 public static void main(String[] args) throws IOException { |
38 final Path top = CreateFileTree.create(); |
39 Path top = CreateFileTree.create(); |
|
40 try { |
|
41 test(top); |
|
42 } finally { |
|
43 TestUtil.removeAll(top); |
|
44 } |
|
45 } |
39 |
46 |
|
47 static void test(final Path top) throws IOException { |
40 for (int i=0; i<5; i++) { |
48 for (int i=0; i<5; i++) { |
41 Set<FileVisitOption> opts = Collections.emptySet(); |
49 Set<FileVisitOption> opts = Collections.emptySet(); |
42 final int maxDepth = i; |
50 final int maxDepth = i; |
43 Files.walkFileTree(top, opts, maxDepth, new SimpleFileVisitor<Path>() { |
51 Files.walkFileTree(top, opts, maxDepth, new SimpleFileVisitor<Path>() { |
44 // compute depth based on relative path to top directory |
52 // compute depth based on relative path to top directory |