DirectoryWalker { public void walk(Path start, CallContext auth) throws IOException{ FileVisitResult result = walk(start, auth, 0); Objects.requireNonNull(result, "FileVisitor returned null"); } DirectoryWalker(DcFileSystemProvider provider, ContainerVisitor visitor, int maxDepth);  DirectoryWalker(DcFileSystemProvider provider, String syntaxAndPattern, int maxDepth); void walk(Path start, CallContext auth);  }
@Test public void testWalk() throws IOException{ ContainerVisitor visitor; visitor = new ContainerVisitor("glob:/te*"); DirectoryWalker walker = new DirectoryWalker(provider,visitor,2); walker.walk(root, callContext); visitor = new ContainerVisitor("glob:/te**"); walker = new DirectoryWalker(provider,visitor,5); walker.walk(root, callContext); TestCase.assertEquals("/testpath/a/b/c", visitor.files.get(0).getPath().toString()); TestCase.assertEquals("/testpath/a/b", visitor.files.get(1).getPath().toString()); TestCase.assertEquals("/testpath/abc/def/xyz", visitor.files.get(3).getPath().toString()); TestCase.assertEquals("/testpath/abc/def/zyx", visitor.files.get(4).getPath().toString()); visitor = new ContainerVisitor("glob:/te**$"); walker = new DirectoryWalker(provider,visitor,5); walker.walk(root, callContext); TestCase.assertEquals("/testpath/a/b/c", visitor.files.get(0).getPath().toString()); TestCase.assertEquals("/testpath/a/b", visitor.files.get(1).getPath().toString()); TestCase.assertEquals("/testpath/abc/def/xyz", visitor.files.get(3).getPath().toString()); TestCase.assertEquals("/testpath/abc/def", visitor.files.get(4).getPath().toString()); visitor = new ContainerVisitor("glob:/te**^"); walker = new DirectoryWalker(provider,visitor,5); walker.walk(root, callContext); TestCase.assertEquals("/testpath/abc/def/zyx", visitor.files.get(0).getPath().toString()); TestCase.assertEquals("/testpath/abc/fed", visitor.files.get(1).getPath().toString()); visitor = new ContainerVisitor("glob:te*"); walker = new DirectoryWalker(provider,visitor, 4); walker.walk(root, callContext); TestCase.assertEquals("/testpath/testfolder", visitor.files.get(0).getPath().toString()); TestCase.assertEquals("/testpath/testgroup", visitor.files.get(1).getPath().toString()); visitor = new ContainerVisitor("glob:te*^"); walker = new DirectoryWalker(provider,visitor, 4); walker.walk(root, callContext); System.out.println(visitor.files.toString()); TestCase.assertEquals("/testpath/testgroup", visitor.files.get(0).getPath().toString()); TestCase.assertTrue(visitor.files.size() == 1); visitor = new ContainerVisitor("glob:te*$"); walker = new DirectoryWalker(provider,visitor, 4); walker.walk(root, callContext); TestCase.assertEquals("/testpath/testfolder", visitor.files.get(0).getPath().toString()); TestCase.assertTrue(visitor.files.size() == 1); Boolean searchGroups = true; Boolean searchFolders = true; visitor = new ContainerVisitor("/testpath", searchGroups, searchFolders); walker = new DirectoryWalker(provider,visitor,5); walker.walk(root, callContext); TestCase.assertEquals("/testpath", visitor.files.get(0).getPath().toString()); TestCase.assertTrue(visitor.files.size() == 1); searchGroups = true; searchFolders = false; visitor = new ContainerVisitor("/testpath", searchGroups, searchFolders); walker = new DirectoryWalker(provider,visitor,5); walker.walk(root, callContext); TestCase.assertTrue(visitor.files.size() == 0); searchGroups = false; searchFolders = true; visitor = new ContainerVisitor("/testpath/*", searchGroups, searchFolders); walker = new DirectoryWalker(provider,visitor,5); walker.walk(root, callContext); TestCase.assertEquals("/testpath/a", visitor.files.get(0).getPath().toString()); TestCase.assertEquals("/testpath/abc", visitor.files.get(1).getPath().toString()); TestCase.assertEquals("/testpath/testfolder", visitor.files.get(2).getPath().toString()); TestCase.assertTrue(visitor.files.size() == 3); searchGroups = true; searchFolders = false; visitor = new ContainerVisitor("/testpath/*", searchGroups, searchFolders); walker = new DirectoryWalker(provider,visitor,5); walker.walk(root, callContext); TestCase.assertEquals("/testpath/testgroup", visitor.files.get(0).getPath().toString()); TestCase.assertTrue(visitor.files.size() == 1); searchGroups = null; searchFolders = null; visitor = new ContainerVisitor("/testpath/test*^", searchGroups, searchFolders); walker = new DirectoryWalker(provider,visitor,5); walker.walk(root, callContext); TestCase.assertEquals("/testpath/testgroup", visitor.files.get(0).getPath().toString()); TestCase.assertTrue(visitor.files.size() == 1); searchGroups = null; searchFolders = null; visitor = new ContainerVisitor("/testpath/test*$", searchGroups, searchFolders); walker = new DirectoryWalker(provider,visitor,5); walker.walk(root, callContext); TestCase.assertEquals("/testpath/testfolder", visitor.files.get(0).getPath().toString()); TestCase.assertTrue(visitor.files.size() == 1); searchGroups = false; searchFolders = true; visitor = new ContainerVisitor(PathUtils.normalize( "/testpath/."), searchGroups, searchFolders); walker = new DirectoryWalker(provider,visitor,5); walker.walk(root, callContext); TestCase.assertEquals("/testpath", visitor.files.get(0).getPath().toString()); TestCase.assertTrue(visitor.files.size() == 1); }