@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 testRepeatedRunWithCache() 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("/folder", EnumSet.of(Path.Type.directory)));
        cache.put(new Path("/", EnumSet.of(Path.Type.directory)), root);

        final AttributedList<Path> folder = new AttributedList<>();
        folder.add(new Path(new Path("/folder", EnumSet.of(Path.Type.directory)), "/t2.gif", EnumSet.of(Path.Type.file)));
        cache.put(new Path("/folder", EnumSet.of(Path.Type.directory)), folder);

        final AttributedList<Path> search1 = new SearchWorker(new Path("/", EnumSet.of(Path.Type.directory)),
            new SearchFilter(".png"), cache, new DisabledListProgressListener()).run(new NullSession(new Host(new TestProtocol())));

        assertTrue(search1.contains(new Path("/t1.png", EnumSet.of(Path.Type.file))));
        assertFalse(search1.contains(new Path("/folder", EnumSet.of(Path.Type.directory))));

        assertTrue(cache.get(new Path("/", EnumSet.of(Path.Type.directory))).contains(new Path("/t1.png", EnumSet.of(Path.Type.file))));
        assertTrue(cache.get(new Path("/", EnumSet.of(Path.Type.directory))).contains(new Path("/folder", EnumSet.of(Path.Type.directory))));
        assertTrue(cache.get(new Path("/folder", EnumSet.of(Path.Type.directory))).contains(
            new Path(new Path("/folder", EnumSet.of(Path.Type.directory)), "/t2.gif", EnumSet.of(Path.Type.file))));

        final AttributedList<Path> search2 = new SearchWorker(new Path("/", EnumSet.of(Path.Type.directory)),
                new NullFilter<>(), cache, new DisabledListProgressListener()).run(new NullSession(new Host(new TestProtocol())));
        assertTrue(search2.contains(new Path("/t1.png", EnumSet.of(Path.Type.file))));
        assertTrue(search2.contains(new Path("/folder", EnumSet.of(Path.Type.directory))));
        assertTrue(cache.get(new Path("/", EnumSet.of(Path.Type.directory))).contains(new Path("/t1.png", EnumSet.of(Path.Type.file))));
        assertTrue(cache.get(new Path("/", EnumSet.of(Path.Type.directory))).contains(new Path("/folder", EnumSet.of(Path.Type.directory))));
        assertTrue(cache.get(new Path("/folder", EnumSet.of(Path.Type.directory))).contains(
            new Path(new Path("/folder", EnumSet.of(Path.Type.directory)), "/t2.gif", EnumSet.of(Path.Type.file))));
    }