@Test public void testSymlink() throws Exception { final Session session = new NullSession(new Host(new TestProtocol())) { @Override @SuppressWarnings("unchecked") public <T> T _getFeature(final Class<T> type) { if(type == Delete.class) { return (T) new Delete() { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) { assertEquals(new Path("/s", EnumSet.of(Path.Type.directory, AbstractPath.Type.symboliclink)), new ArrayList<>(files.keySet()).get(0)); } @Override public boolean isRecursive() { return false; } }; } return super._getFeature(type); } @Override public AttributedList<Path> list(final Path file, final ListProgressListener listener) { fail(); return null; } }; final DeleteWorker worker = new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(new Path("/s", EnumSet.of(Path.Type.directory, AbstractPath.Type.symboliclink))), PathCache.empty(), new DisabledProgressListener()); worker.run(session); }
@Override public List<Path> run(final Session<?> session) throws BackgroundException { final Delete delete = session.getFeature(Delete.class); final ListService list = session.getFeature(ListService.class); final Map<Path, TransferStatus> recursive = new LinkedHashMap<>(); for(Path file : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } recursive.putAll(this.compile(session.getHost(), delete, list, new WorkerListProgressListener(this, listener), file)); } delete.delete(recursive, prompt, new Delete.Callback() { @Override public void delete(final Path file) { listener.message(MessageFormat.format(LocaleFactory.localizedString("Deleting {0}", "Status"), file.getName())); } }); return new ArrayList<>(recursive.keySet()); }
DeleteWorker extends Worker<List<Path>> { @Override public List<Path> run(final Session<?> session) throws BackgroundException { final Delete delete = session.getFeature(Delete.class); final ListService list = session.getFeature(ListService.class); final Map<Path, TransferStatus> recursive = new LinkedHashMap<>(); for(Path file : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } recursive.putAll(this.compile(session.getHost(), delete, list, new WorkerListProgressListener(this, listener), file)); } delete.delete(recursive, prompt, new Delete.Callback() { @Override public void delete(final Path file) { listener.message(MessageFormat.format(LocaleFactory.localizedString("Deleting {0}", "Status"), file.getName())); } }); return new ArrayList<>(recursive.keySet()); } }
DeleteWorker extends Worker<List<Path>> { @Override public List<Path> run(final Session<?> session) throws BackgroundException { final Delete delete = session.getFeature(Delete.class); final ListService list = session.getFeature(ListService.class); final Map<Path, TransferStatus> recursive = new LinkedHashMap<>(); for(Path file : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } recursive.putAll(this.compile(session.getHost(), delete, list, new WorkerListProgressListener(this, listener), file)); } delete.delete(recursive, prompt, new Delete.Callback() { @Override public void delete(final Path file) { listener.message(MessageFormat.format(LocaleFactory.localizedString("Deleting {0}", "Status"), file.getName())); } }); return new ArrayList<>(recursive.keySet()); } DeleteWorker(final LoginCallback prompt, final List<Path> files, final Cache<Path> cache, final ProgressListener listener);  DeleteWorker(final LoginCallback prompt, final List<Path> files, final Cache<Path> cache, final Filter<Path> filter, final ProgressListener listener); }
DeleteWorker extends Worker<List<Path>> { @Override public List<Path> run(final Session<?> session) throws BackgroundException { final Delete delete = session.getFeature(Delete.class); final ListService list = session.getFeature(ListService.class); final Map<Path, TransferStatus> recursive = new LinkedHashMap<>(); for(Path file : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } recursive.putAll(this.compile(session.getHost(), delete, list, new WorkerListProgressListener(this, listener), file)); } delete.delete(recursive, prompt, new Delete.Callback() { @Override public void delete(final Path file) { listener.message(MessageFormat.format(LocaleFactory.localizedString("Deleting {0}", "Status"), file.getName())); } }); return new ArrayList<>(recursive.keySet()); } DeleteWorker(final LoginCallback prompt, final List<Path> files, final Cache<Path> cache, final ProgressListener listener);  DeleteWorker(final LoginCallback prompt, final List<Path> files, final Cache<Path> cache, final Filter<Path> filter, final ProgressListener listener); @Override List<Path> run(final Session<?> session); @Override void cleanup(final List<Path> deleted); @Override String getActivity(); @Override List<Path> initialize(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); }
DeleteWorker extends Worker<List<Path>> { @Override public List<Path> run(final Session<?> session) throws BackgroundException { final Delete delete = session.getFeature(Delete.class); final ListService list = session.getFeature(ListService.class); final Map<Path, TransferStatus> recursive = new LinkedHashMap<>(); for(Path file : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } recursive.putAll(this.compile(session.getHost(), delete, list, new WorkerListProgressListener(this, listener), file)); } delete.delete(recursive, prompt, new Delete.Callback() { @Override public void delete(final Path file) { listener.message(MessageFormat.format(LocaleFactory.localizedString("Deleting {0}", "Status"), file.getName())); } }); return new ArrayList<>(recursive.keySet()); } DeleteWorker(final LoginCallback prompt, final List<Path> files, final Cache<Path> cache, final ProgressListener listener);  DeleteWorker(final LoginCallback prompt, final List<Path> files, final Cache<Path> cache, final Filter<Path> filter, final ProgressListener listener); @Override List<Path> run(final Session<?> session); @Override void cleanup(final List<Path> deleted); @Override String getActivity(); @Override List<Path> initialize(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }