@Override
    public AttributedList<Path> run(final Session<?> session) throws BackgroundException {
        // Run recursively
        final Search feature = session.getFeature(Search.class);
        if(log.isDebugEnabled()) {
            log.debug(String.format("Run with feature %s", feature));
        }
        return this.search(feature, directory);
    }
@Test
    public void testRun() throws Exception {
        final PathCache cache = new PathCache(Integer.MAX_VALUE);
        final AttributedList<Path> root = new AttributedList<>();
        root.add(new Path("/t1.png", EnumSet.of(Path.Type.file)));
        root.add(new Path("/t1.gif", EnumSet.of(Path.Type.file)));
        final Path folder = new Path("/folder", EnumSet.of(Path.Type.directory));
        root.add(folder);
        root.add(new Path("/folder2", EnumSet.of(Path.Type.directory)));
        cache.put(new Path("/", EnumSet.of(Path.Type.directory)), root);
        final AttributedList<Path> folderContents = new AttributedList<>();
        folderContents.add(new Path(folder, "/t2.png", EnumSet.of(Path.Type.file)));
        folderContents.add(new Path(folder, "/t2.gif", EnumSet.of(Path.Type.file)));
        final Path subfolder = new Path(folder, "/subfolder", EnumSet.of(Path.Type.directory));
        folderContents.add(subfolder);
        cache.put(folder, folderContents);
        final AttributedList<Path> subfolderContents = new AttributedList<>();
        subfolderContents.add(new Path(subfolder, "t2.png", EnumSet.of(Path.Type.file)));
        subfolderContents.add(new Path(subfolder, "t2.gif", EnumSet.of(Path.Type.file)));
        cache.put(subfolder, subfolderContents);
        final SearchWorker search = new SearchWorker(new Path("/", EnumSet.of(Path.Type.directory)),
            new SearchFilter(".png"), cache, new DisabledListProgressListener());
        final AttributedList<Path> found = search.run(new NullSession(new Host(new TestProtocol())));
        assertTrue(found.contains(new Path("/t1.png", EnumSet.of(Path.Type.file))));
        assertFalse(found.contains(new Path("/t1.gif", EnumSet.of(Path.Type.file))));
        assertFalse(found.contains(new Path("/t2.png", EnumSet.of(Path.Type.file))));
        assertFalse(found.contains(new Path("/t2.gif", EnumSet.of(Path.Type.file))));
        assertTrue(found.contains(folder));
        assertTrue(found.contains(new Path(folder, "/t2.png", EnumSet.of(Path.Type.file))));
        assertTrue(found.contains(subfolder));
        assertTrue(found.contains(new Path(subfolder, "/t2.png", EnumSet.of(Path.Type.file))));
        assertFalse(found.contains(new Path(new Path("/folder2", EnumSet.of(Path.Type.directory)), "/t2.gif", EnumSet.of(Path.Type.file))));
        assertFalse(found.contains(new Path("/folder2", EnumSet.of(Path.Type.directory))));
    }