Search in sources :

Example 1 with TransferAdapter

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);
}
Also used : SocketException(java.net.SocketException) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) TestProtocol(ch.cyberduck.core.TestProtocol) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) ConnectionRefusedException(ch.cyberduck.core.exception.ConnectionRefusedException) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) NullLocal(ch.cyberduck.core.NullLocal) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Path(ch.cyberduck.core.Path) TransferAdapter(ch.cyberduck.core.transfer.TransferAdapter) Host(ch.cyberduck.core.Host) AbstractController(ch.cyberduck.core.AbstractController) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) TransferItem(ch.cyberduck.core.transfer.TransferItem) BackgroundException(ch.cyberduck.core.exception.BackgroundException) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) NullTransferSession(ch.cyberduck.core.NullTransferSession) Test(org.junit.Test)

Example 2 with TransferAdapter

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());
}
Also used : TestProtocol(ch.cyberduck.core.TestProtocol) TransferAdapter(ch.cyberduck.core.transfer.TransferAdapter) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) StatelessSessionPool(ch.cyberduck.core.pool.StatelessSessionPool) AbstractController(ch.cyberduck.core.AbstractController) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Test(org.junit.Test)

Aggregations

AbstractController (ch.cyberduck.core.AbstractController)2 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)2 DisabledTranscriptListener (ch.cyberduck.core.DisabledTranscriptListener)2 Host (ch.cyberduck.core.Host)2 NullSession (ch.cyberduck.core.NullSession)2 TestLoginConnectionService (ch.cyberduck.core.TestLoginConnectionService)2 TestProtocol (ch.cyberduck.core.TestProtocol)2 DownloadTransfer (ch.cyberduck.core.transfer.DownloadTransfer)2 TransferAdapter (ch.cyberduck.core.transfer.TransferAdapter)2 TransferOptions (ch.cyberduck.core.transfer.TransferOptions)2 DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)2 Test (org.junit.Test)2 NullLocal (ch.cyberduck.core.NullLocal)1 NullTransferSession (ch.cyberduck.core.NullTransferSession)1 Path (ch.cyberduck.core.Path)1 Session (ch.cyberduck.core.Session)1 BackgroundException (ch.cyberduck.core.exception.BackgroundException)1 ConnectionRefusedException (ch.cyberduck.core.exception.ConnectionRefusedException)1 DefaultSessionPool (ch.cyberduck.core.pool.DefaultSessionPool)1 StatelessSessionPool (ch.cyberduck.core.pool.StatelessSessionPool)1