use of ch.cyberduck.core.transfer.TransferAdapter in project cyberduck by iterate-ch.
the class TransferBackgroundActionTest method testResumeOnRetryWithException.
@Test
public void testResumeOnRetryWithException() {
final AtomicBoolean alert = new AtomicBoolean();
final AbstractController controller = new AbstractController() {
@Override
public void invoke(final MainAction runnable, final boolean wait) {
runnable.run();
}
};
final Host host = new Host(new TestProtocol(), "test.cyberduck.ch");
final TransferOptions options = new TransferOptions();
final TransferBackgroundAction action = new TransferBackgroundAction(controller, new DefaultSessionPool(new TestLoginConnectionService(), new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), host) {
@Override
public Session<?> borrow(final BackgroundActionState callback) throws BackgroundException {
throw new ConnectionRefusedException("d", new SocketException());
}
}, SessionPool.DISCONNECTED, new TransferAdapter(), new DownloadTransfer(host, Collections.singletonList(new TransferItem(new Path("/home/test", EnumSet.of(Path.Type.file)), new NullLocal("/t")))), options) {
@Override
public boolean alert(final BackgroundException failure) {
final boolean alerted = alert.get();
alert.set(true);
return !alerted;
}
};
assertFalse(alert.get());
// Connect, prepare and run
new BackgroundCallable<Boolean>(action, controller).call();
assertTrue(alert.get());
assertTrue(action.hasFailed());
// assertTrue(options.resumeRequested);
}
use of ch.cyberduck.core.transfer.TransferAdapter in project cyberduck by iterate-ch.
the class TransferBackgroundActionTest method testWorkerImplementationDefaultConcurrent.
@Test
public void testWorkerImplementationDefaultConcurrent() {
final AbstractController controller = new AbstractController() {
@Override
public void invoke(final MainAction runnable, final boolean wait) {
runnable.run();
}
};
final Host host = new Host(new TestProtocol(), "l");
host.setTransfer(Host.TransferType.concurrent);
assertEquals(ConcurrentTransferWorker.class, new TransferBackgroundAction(controller, new StatelessSessionPool(new TestLoginConnectionService(), new NullSession(host), new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), SessionPool.DISCONNECTED, new TransferAdapter(), new UploadTransfer(host, Collections.emptyList()), new TransferOptions()).worker.getClass());
assertEquals(ConcurrentTransferWorker.class, new TransferBackgroundAction(controller, new StatelessSessionPool(new TestLoginConnectionService(), new NullSession(host), new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), SessionPool.DISCONNECTED, new TransferAdapter(), new DownloadTransfer(host, Collections.emptyList()), new TransferOptions()).worker.getClass());
}
Aggregations