@Override
    public boolean find(final Path file, final ListProgressListener listener) throws BackgroundException {
        if(file.isRoot()) {
            return delegate.find(file, listener);
        }
        if(cache.isValid(file.getParent())) {
            final AttributedList<Path> list = cache.get(file.getParent());
            final Path found = list.find(new ListFilteringFeature.ListFilteringPredicate(sensitivity, file));
            if(found != null) {
                if(log.isDebugEnabled()) {
                    log.debug(String.format("Found %s in cache", file));
                }
                return true;
            }
            if(log.isDebugEnabled()) {
                log.debug(String.format("Cached directory listing does not contain %s", file));
            }
            return false;
        }
        final CachingListProgressListener caching = new CachingListProgressListener(cache);
        final boolean found = delegate.find(file, new ProxyListProgressListener(listener, caching));
        caching.cache();
        return found;
    }
@Test
    public void testFindCaseSensitive() throws Exception {
        final PathCache cache = new PathCache(1);
        final Path directory = new Path("/", EnumSet.of(Path.Type.directory));
        final Path file = new Path(directory, "f", EnumSet.of(Path.Type.file));
        final CachingFindFeature feature = new CachingFindFeature(Protocol.Case.sensitive, cache, new DefaultFindFeature(new NullSession(new Host(new TestProtocol())) {
            @Override
            public AttributedList<Path> list(final Path folder, final ListProgressListener listener) throws ConnectionCanceledException {
                listener.chunk(folder, new AttributedList<>(Collections.singleton(file)));
                return new AttributedList<>(Collections.singleton(file));
            }

            @Override
            public Protocol.Case getCaseSensitivity() {
                return Protocol.Case.sensitive;
            }
        }));
        assertTrue(feature.find(file, new DisabledListProgressListener()));
        assertEquals(1, cache.size());
        assertTrue(cache.isCached(directory));
        assertFalse(feature.find(new Path(directory, "F", EnumSet.of(Path.Type.file)), new DisabledListProgressListener()));
    }