@Override
    public Transfer withCache(final Cache<Path> cache) {
        this.cache = cache;
        return this;
    }
@Test
    public void testCacheResume() throws Exception {
        final AtomicInteger c1 = new AtomicInteger();
        final AtomicInteger c2 = new AtomicInteger();
        final NullLocal local = new NullLocal("t") {
            @Override
            public AttributedList<Local> list() {
                AttributedList<Local> l = new AttributedList<>();
                l.add(new NullLocal(this.getAbsolute(), "a") {
                    @Override
                    public boolean exists() {
                        return true;
                    }
                });
                l.add(new NullLocal(this.getAbsolute(), "b") {
                    @Override
                    public boolean exists() {
                        return true;
                    }
                });
                l.add(new NullLocal(this.getAbsolute(), "c") {
                    @Override
                    public boolean exists() {
                        return true;
                    }
                });
                return l;
            }

            @Override
            public boolean isFile() {
                return false;
            }

            @Override
            public boolean isDirectory() {
                return true;
            }

            @Override
            public boolean exists() {
                return true;
            }
        };
        final Path root = new Path("/t", EnumSet.of(Path.Type.directory));
        final NullSession session = new NullSession(new Host(new TestProtocol())) {
            @Override
            public AttributedList<Path> list(final Path folder, final ListProgressListener listener) throws ConnectionCanceledException {
                final AttributedList<Path> list = new AttributedList<>();
                if(folder.equals(root.getParent())) {
                    c1.incrementAndGet();
                    list.add(root);
                }
                if(folder.equals(root)) {
                    c2.incrementAndGet();
                }
                listener.chunk(folder, list);
                return list;
            }
        };
        final PathCache cache = new PathCache(2);
        final Transfer t = new UploadTransfer(new Host(new TestProtocol()), root, local) {
            @Override
            public void transfer(final Session<?> source, final Session<?> destination, final Path file, Local local,
                                 final TransferOptions options, final TransferStatus overall, final TransferStatus segment,
                                 final ConnectionCallback connectionCallback,
                                 final ProgressListener listener, final StreamListener streamListener) {
                assertTrue(options.resumeRequested);
            }
        }.withCache(cache);
        final TransferOptions options = new TransferOptions();
        options.resumeRequested = true;
        new SingleTransferWorker(session, null, t, options, new TransferSpeedometer(t), new DisabledTransferPrompt() {
            @Override
            public TransferAction prompt(final TransferItem file) {
                fail();
                return null;
            }
        }, new DisabledTransferErrorCallback(),
            new DisabledProgressListener(), new DisabledStreamListener(), new DisabledLoginCallback(), new DisabledNotificationService()).run(session);
        assertEquals(1, c1.get());
        assertEquals(1, c2.get());
        assertTrue(cache.isCached(root.getParent()));
        assertTrue(cache.isCached(root));
    }