protected Path search(final Path file, final ListProgressListener listener) throws BackgroundException {
        final AttributedList<Path> list = session._getFeature(ListService.class).list(file.getParent(), listener);
        // Try to match path only as the version might have changed in the meantime
        final Path found = list.find(new ListFilteringPredicate(session.getCaseSensitivity(), file));
        if(null == found) {
            if(log.isWarnEnabled()) {
                log.warn(String.format("File %s not found in directory listing", file));
            }
        }
        else {
            if(log.isDebugEnabled()) {
                log.debug(String.format("Return attributes %s for file %s", found.attributes(), file));
            }
        }
        return found;
    }
@Test
    public void testSearch() {
        assertTrue(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file))).test(
                new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file))
        ));
        assertTrue(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file))).test(
                new Path(Home.ROOT, "F", EnumSet.of(Path.Type.file))
        ));
        assertTrue(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withVersionId("v1"))).test(
                new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withVersionId("v1"))
        ));
        assertFalse(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withVersionId("v1"))).test(
                new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withVersionId("v2"))
        ));
        assertTrue(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().withVersionId("v1"))).test(
                new Path(Home.ROOT, "f", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().withVersionId("v2"))
        ));
        assertTrue(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withFileId("v1"))).test(
                new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withFileId("v1"))
        ));
        assertFalse(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withFileId("v1"))).test(
                new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withFileId("v2"))
        ));
        assertFalse(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().withFileId("v1"))).test(
                new Path(Home.ROOT, "f", EnumSet.of(Path.Type.directory)).withAttributes(new PathAttributes().withFileId("v2"))
        ));
        assertTrue(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file))).test(
                new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withVersionId("v1"))
        ));
        assertFalse(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes().withVersionId("v1"))).test(
                new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes())
        ));
        assertFalse(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file))).test(
                new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file)).withAttributes(new PathAttributes() {
                    @Override
                    public boolean isDuplicate() {
                        return true;
                    }
                })
        ));
        assertFalse(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.sensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file))).test(
                new Path(Home.ROOT, "F", EnumSet.of(Path.Type.file))
        ));
        assertFalse(new ListFilteringFeature.ListFilteringPredicate(Protocol.Case.insensitive, new Path(Home.ROOT, "f", EnumSet.of(Path.Type.file))).test(
                new Path(Home.ROOT, "f2", EnumSet.of(Path.Type.file))
        ));
    }