@Test public void testBorrow() throws Exception { final Host host = new Host(new TestProtocol(), "test.cyberduck.ch"); final Transfer t = new UploadTransfer(host, new Path("/t", EnumSet.of(Path.Type.directory)), new NullLocal("l")); final LoginConnectionService connection = new TestLoginConnectionService(); final DefaultSessionPool pool = new DefaultSessionPool(connection, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), PathCache.empty(), new DisabledTranscriptListener(), host); final ConcurrentTransferWorker worker = new ConcurrentTransferWorker( pool, SessionPool.DISCONNECTED, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt(), new DisabledTransferErrorCallback(), new DisabledLoginCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledNotificationService() ); assertNotSame(worker.borrow(ConcurrentTransferWorker.Connection.source), worker.borrow(ConcurrentTransferWorker.Connection.source)); worker.cleanup(true); }
@Override protected Session<?> borrow(final Connection type) throws BackgroundException { switch(type) { case source: return source.borrow(new BackgroundActionState() { @Override public boolean isCanceled() { return ConcurrentTransferWorker.this.isCanceled(); } @Override public boolean isRunning() { return true; } }); case destination: return destination.borrow(new BackgroundActionState() { @Override public boolean isCanceled() { return ConcurrentTransferWorker.this.isCanceled(); } @Override public boolean isRunning() { return true; } }); } return null; }
ConcurrentTransferWorker extends AbstractTransferWorker { @Override protected Session<?> borrow(final Connection type) throws BackgroundException { switch(type) { case source: return source.borrow(new BackgroundActionState() { @Override public boolean isCanceled() { return ConcurrentTransferWorker.this.isCanceled(); } @Override public boolean isRunning() { return true; } }); case destination: return destination.borrow(new BackgroundActionState() { @Override public boolean isCanceled() { return ConcurrentTransferWorker.this.isCanceled(); } @Override public boolean isRunning() { return true; } }); } return null; } }
ConcurrentTransferWorker extends AbstractTransferWorker { @Override protected Session<?> borrow(final Connection type) throws BackgroundException { switch(type) { case source: return source.borrow(new BackgroundActionState() { @Override public boolean isCanceled() { return ConcurrentTransferWorker.this.isCanceled(); } @Override public boolean isRunning() { return true; } }); case destination: return destination.borrow(new BackgroundActionState() { @Override public boolean isCanceled() { return ConcurrentTransferWorker.this.isCanceled(); } @Override public boolean isRunning() { return true; } }); } return null; } ConcurrentTransferWorker(final SessionPool source,
                                    final SessionPool destination,
                                    final Transfer transfer,
                                    final TransferOptions options,
                                    final TransferSpeedometer meter,
                                    final TransferPrompt prompt,
                                    final TransferErrorCallback error,
                                    final ConnectionCallback connect,
                                    final ProgressListener progressListener,
                                    final StreamListener streamListener,
                                    final NotificationService notification);  ConcurrentTransferWorker(final SessionPool source,
                                    final SessionPool destination,
                                    final Transfer transfer,
                                    final ThreadPool.Priority priority,
                                    final TransferOptions options,
                                    final TransferSpeedometer meter,
                                    final TransferPrompt prompt,
                                    final TransferErrorCallback error,
                                    final ConnectionCallback connect,
                                    final ProgressListener progressListener,
                                    final StreamListener streamListener,
                                    final NotificationService notification); }
ConcurrentTransferWorker extends AbstractTransferWorker { @Override protected Session<?> borrow(final Connection type) throws BackgroundException { switch(type) { case source: return source.borrow(new BackgroundActionState() { @Override public boolean isCanceled() { return ConcurrentTransferWorker.this.isCanceled(); } @Override public boolean isRunning() { return true; } }); case destination: return destination.borrow(new BackgroundActionState() { @Override public boolean isCanceled() { return ConcurrentTransferWorker.this.isCanceled(); } @Override public boolean isRunning() { return true; } }); } return null; } ConcurrentTransferWorker(final SessionPool source,
                                    final SessionPool destination,
                                    final Transfer transfer,
                                    final TransferOptions options,
                                    final TransferSpeedometer meter,
                                    final TransferPrompt prompt,
                                    final TransferErrorCallback error,
                                    final ConnectionCallback connect,
                                    final ProgressListener progressListener,
                                    final StreamListener streamListener,
                                    final NotificationService notification);  ConcurrentTransferWorker(final SessionPool source,
                                    final SessionPool destination,
                                    final Transfer transfer,
                                    final ThreadPool.Priority priority,
                                    final TransferOptions options,
                                    final TransferSpeedometer meter,
                                    final TransferPrompt prompt,
                                    final TransferErrorCallback error,
                                    final ConnectionCallback connect,
                                    final ProgressListener progressListener,
                                    final StreamListener streamListener,
                                    final NotificationService notification); @Override Future<TransferStatus> submit(final TransferCallable callable); @Override void await(); @Override void cleanup(final Boolean result); @Override String toString(); }
ConcurrentTransferWorker extends AbstractTransferWorker { @Override protected Session<?> borrow(final Connection type) throws BackgroundException { switch(type) { case source: return source.borrow(new BackgroundActionState() { @Override public boolean isCanceled() { return ConcurrentTransferWorker.this.isCanceled(); } @Override public boolean isRunning() { return true; } }); case destination: return destination.borrow(new BackgroundActionState() { @Override public boolean isCanceled() { return ConcurrentTransferWorker.this.isCanceled(); } @Override public boolean isRunning() { return true; } }); } return null; } ConcurrentTransferWorker(final SessionPool source,
                                    final SessionPool destination,
                                    final Transfer transfer,
                                    final TransferOptions options,
                                    final TransferSpeedometer meter,
                                    final TransferPrompt prompt,
                                    final TransferErrorCallback error,
                                    final ConnectionCallback connect,
                                    final ProgressListener progressListener,
                                    final StreamListener streamListener,
                                    final NotificationService notification);  ConcurrentTransferWorker(final SessionPool source,
                                    final SessionPool destination,
                                    final Transfer transfer,
                                    final ThreadPool.Priority priority,
                                    final TransferOptions options,
                                    final TransferSpeedometer meter,
                                    final TransferPrompt prompt,
                                    final TransferErrorCallback error,
                                    final ConnectionCallback connect,
                                    final ProgressListener progressListener,
                                    final StreamListener streamListener,
                                    final NotificationService notification); @Override Future<TransferStatus> submit(final TransferCallable callable); @Override void await(); @Override void cleanup(final Boolean result); @Override String toString();  }