Search in sources :

Example 6 with StatelessSessionPool

use of ch.cyberduck.core.pool.StatelessSessionPool in project cyberduck by iterate-ch.

the class SessionBackgroundActionTest method testRetrySocket.

@Test
public void testRetrySocket() {
    final BackgroundException failure = new BackgroundException(new SocketTimeoutException(""));
    SessionBackgroundAction<Void> a = new SessionBackgroundAction<Void>(new StatelessSessionPool(new TestLoginConnectionService(), new NullSession(new Host(new TestProtocol(), "t")), new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new AlertCallback() {

        @Override
        public boolean alert(final Host repeatableBackgroundAction, final BackgroundException f, final StringBuilder transcript) {
            assertEquals(failure, f);
            return false;
        }
    }, new DisabledProgressListener()) {

        @Override
        public Void run(final Session<?> session) throws BackgroundException {
            throw failure;
        }
    };
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) StatelessSessionPool(ch.cyberduck.core.pool.StatelessSessionPool) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) SocketTimeoutException(java.net.SocketTimeoutException) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) BackgroundException(ch.cyberduck.core.exception.BackgroundException) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 7 with StatelessSessionPool

use of ch.cyberduck.core.pool.StatelessSessionPool 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)

Example 8 with StatelessSessionPool

use of ch.cyberduck.core.pool.StatelessSessionPool in project cyberduck by iterate-ch.

the class TransferBackgroundActionTest method testDuplicate.

@Test
public void testDuplicate() throws Exception {
    final Host host = new Host(new TestProtocol(), "test.cyberduck.ch") {

        @Override
        public Credentials getCredentials() {
            return new Credentials(System.getProperties().getProperty("sftp.user"), System.getProperties().getProperty("sftp.password"));
        }
    };
    final Path directory = new Path("/home/jenkins/transfer", EnumSet.of(Path.Type.directory));
    final Path test = new Path(directory, "test", EnumSet.of(Path.Type.file));
    test.attributes().setSize(0L);
    final Path copy = new Path(directory, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final CopyTransfer t = new CopyTransfer(host, host, Collections.singletonMap(test, copy)) {

        @Override
        public TransferAction action(final Session<?> source, final Session<?> destination, final boolean resumeRequested, final boolean reloadRequested, final TransferPrompt prompt, final ListProgressListener listener) {
            return TransferAction.overwrite;
        }
    };
    final AbstractController controller = new AbstractController() {

        @Override
        public void invoke(final MainAction runnable, final boolean wait) {
            runnable.run();
        }
    };
    final AtomicBoolean start = new AtomicBoolean();
    final AtomicBoolean stop = new AtomicBoolean();
    final Session session = new NullTransferSession(host);
    final Session destination = new NullTransferSession(host);
    final TransferBackgroundAction action = new TransferBackgroundAction(controller, new StatelessSessionPool(new TestLoginConnectionService(), session, new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new StatelessSessionPool(new TestLoginConnectionService(), destination, new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new TransferListener() {

        @Override
        public void transferDidStart(final Transfer transfer) {
            assertEquals(t, transfer);
            start.set(true);
        }

        @Override
        public void transferDidStop(final Transfer transfer) {
            assertEquals(t, transfer);
            stop.set(true);
        }

        @Override
        public void transferDidProgress(final Transfer transfer, final TransferProgress status) {
        // 
        }
    }, t, new TransferOptions());
    action.prepare();
    action.call();
    assertTrue(destination.isConnected());
    action.finish();
    assertFalse(action.hasFailed());
    assertTrue(start.get());
    assertTrue(stop.get());
    assertTrue(t.isComplete());
    assertNotNull(t.getTimestamp());
}
Also used : Path(ch.cyberduck.core.Path) TransferListener(ch.cyberduck.core.transfer.TransferListener) TestProtocol(ch.cyberduck.core.TestProtocol) Host(ch.cyberduck.core.Host) StatelessSessionPool(ch.cyberduck.core.pool.StatelessSessionPool) AbstractController(ch.cyberduck.core.AbstractController) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) TransferProgress(ch.cyberduck.core.transfer.TransferProgress) NullTransferSession(ch.cyberduck.core.NullTransferSession) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) CopyTransfer(ch.cyberduck.core.transfer.CopyTransfer) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) CopyTransfer(ch.cyberduck.core.transfer.CopyTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) ListProgressListener(ch.cyberduck.core.ListProgressListener) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Credentials(ch.cyberduck.core.Credentials) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) NullTransferSession(ch.cyberduck.core.NullTransferSession) TransferPrompt(ch.cyberduck.core.transfer.TransferPrompt) Test(org.junit.Test)

Example 9 with StatelessSessionPool

use of ch.cyberduck.core.pool.StatelessSessionPool in project cyberduck by iterate-ch.

the class SessionListWorkerTest method testCacheListCanceledWithController.

@Test
public void testCacheListCanceledWithController() throws Exception {
    final Host host = new Host(new TestProtocol(), "localhost");
    final Session<?> session = new NullSession(host) {

        @Override
        public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
            throw new ListCanceledException(AttributedList.<Path>emptyList());
        }
    };
    final PathCache cache = new PathCache(1);
    final Path directory = new Path("/home/notfound", EnumSet.of(Path.Type.directory));
    cache.put(directory, new AttributedList<>(Collections.singletonList(new Path(directory, "f", EnumSet.of(Path.Type.file)))));
    final SessionListWorker worker = new SessionListWorker(cache, 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, new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), worker));
    assertNotNull(task.get());
    assertTrue(cache.containsKey(directory));
    assertEquals(1, cache.get(directory).size());
}
Also used : StatelessSessionPool(ch.cyberduck.core.pool.StatelessSessionPool) MainAction(ch.cyberduck.core.threading.MainAction) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) ListCanceledException(ch.cyberduck.core.exception.ListCanceledException) Test(org.junit.Test)

Aggregations

StatelessSessionPool (ch.cyberduck.core.pool.StatelessSessionPool)9 DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)9 Test (org.junit.Test)9 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)7 DisabledTranscriptListener (ch.cyberduck.core.DisabledTranscriptListener)7 Host (ch.cyberduck.core.Host)7 NullSession (ch.cyberduck.core.NullSession)7 TestLoginConnectionService (ch.cyberduck.core.TestLoginConnectionService)7 TestProtocol (ch.cyberduck.core.TestProtocol)7 Session (ch.cyberduck.core.Session)6 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)4 BackgroundException (ch.cyberduck.core.exception.BackgroundException)4 AbstractController (ch.cyberduck.core.AbstractController)3 DownloadTransfer (ch.cyberduck.core.transfer.DownloadTransfer)3 TransferOptions (ch.cyberduck.core.transfer.TransferOptions)3 UploadTransfer (ch.cyberduck.core.transfer.UploadTransfer)3 ListProgressListener (ch.cyberduck.core.ListProgressListener)2 NullTransferSession (ch.cyberduck.core.NullTransferSession)2 Path (ch.cyberduck.core.Path)2 MainAction (ch.cyberduck.core.threading.MainAction)2