@Test public void testCacheNotFoundWithController() throws Exception { final Host host = new Host(new TestProtocol(), "localhost"); final Session<?> session = new NullTransferSession(host); final PathCache cache = new PathCache(1); final SessionListWorker worker = new SessionListWorker(cache, new Path("/home/notfound", EnumSet.of(Path.Type.directory)), new DisabledListProgressListener()); final Controller c = new AbstractController() { @Override public void invoke(final MainAction runnable, final boolean wait) { runnable.run(); } }; final Future<AttributedList<Path>> task = c.background(new WorkerBackgroundAction<AttributedList<Path>>(c, new StatelessSessionPool( new TestLoginConnectionService(), session, PathCache.empty(), new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), worker)); assertTrue(task.get().isEmpty()); }
@Override public AttributedList<Path> run(final Session<?> session) throws BackgroundException { try { if(this.isCached()) { final AttributedList<Path> list = cache.get(directory); listener.chunk(directory, list); return list; } final ListService service = session.getFeature(ListService.class).withCache(cache); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", service)); } return service.list(directory, listener); } catch(ListCanceledException e) { return e.getChunk(); } }
SessionListWorker extends Worker<AttributedList<Path>> { @Override public AttributedList<Path> run(final Session<?> session) throws BackgroundException { try { if(this.isCached()) { final AttributedList<Path> list = cache.get(directory); listener.chunk(directory, list); return list; } final ListService service = session.getFeature(ListService.class).withCache(cache); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", service)); } return service.list(directory, listener); } catch(ListCanceledException e) { return e.getChunk(); } } }
SessionListWorker extends Worker<AttributedList<Path>> { @Override public AttributedList<Path> run(final Session<?> session) throws BackgroundException { try { if(this.isCached()) { final AttributedList<Path> list = cache.get(directory); listener.chunk(directory, list); return list; } final ListService service = session.getFeature(ListService.class).withCache(cache); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", service)); } return service.list(directory, listener); } catch(ListCanceledException e) { return e.getChunk(); } } SessionListWorker(final Cache<Path> cache, final Path directory, final ListProgressListener listener); }
SessionListWorker extends Worker<AttributedList<Path>> { @Override public AttributedList<Path> run(final Session<?> session) throws BackgroundException { try { if(this.isCached()) { final AttributedList<Path> list = cache.get(directory); listener.chunk(directory, list); return list; } final ListService service = session.getFeature(ListService.class).withCache(cache); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", service)); } return service.list(directory, listener); } catch(ListCanceledException e) { return e.getChunk(); } } SessionListWorker(final Cache<Path> cache, final Path directory, final ListProgressListener listener); @Override AttributedList<Path> run(final Session<?> session); @Override void cleanup(final AttributedList<Path> list); @Override String getActivity(); @Override AttributedList<Path> initialize(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); }
SessionListWorker extends Worker<AttributedList<Path>> { @Override public AttributedList<Path> run(final Session<?> session) throws BackgroundException { try { if(this.isCached()) { final AttributedList<Path> list = cache.get(directory); listener.chunk(directory, list); return list; } final ListService service = session.getFeature(ListService.class).withCache(cache); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", service)); } return service.list(directory, listener); } catch(ListCanceledException e) { return e.getChunk(); } } SessionListWorker(final Cache<Path> cache, final Path directory, final ListProgressListener listener); @Override AttributedList<Path> run(final Session<?> session); @Override void cleanup(final AttributedList<Path> list); @Override String getActivity(); @Override AttributedList<Path> initialize(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }