Search in sources :

Example 81 with NullSession

use of ch.cyberduck.core.NullSession 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 82 with NullSession

use of ch.cyberduck.core.NullSession 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 83 with NullSession

use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.

the class CopyTransferTest method testList.

@Test
public void testList() throws Exception {
    Transfer t = new CopyTransfer(new Host(new TestProtocol()), new Host(new TestProtocol()), new HashMap<>(Collections.singletonMap(new Path("/s", EnumSet.of(Path.Type.directory)), new Path("/t", EnumSet.of(Path.Type.directory)))));
    final NullSession session = new NullSession(new Host(new TestProtocol())) {

        @Override
        public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
            final AttributedList<Path> children = new AttributedList<Path>();
            children.add(new Path("/s/c", EnumSet.of(Path.Type.file)));
            return children;
        }
    };
    assertEquals(Collections.singletonList(new TransferItem(new Path("/s/c", EnumSet.of(Path.Type.file)))), t.list(session, new Path("/s", EnumSet.of(Path.Type.directory)), null, new DisabledListProgressListener()));
}
Also used : Path(ch.cyberduck.core.Path) TestProtocol(ch.cyberduck.core.TestProtocol) AttributedList(ch.cyberduck.core.AttributedList) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) ListProgressListener(ch.cyberduck.core.ListProgressListener) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) Test(org.junit.Test)

Example 84 with NullSession

use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.

the class DeleteWorkerTest method testCompileRecursiveDeleteSupportedMultipleFilesAsArgument.

@Test
public void testCompileRecursiveDeleteSupportedMultipleFilesAsArgument() throws Exception {
    final Session session = new NullSession(new Host(new TestProtocol())) {

        @Override
        @SuppressWarnings("unchecked")
        public <T> T _getFeature(final Class<T> type) {
            if (type == Delete.class) {
                return (T) new Delete() {

                    @Override
                    public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) {
                        assertEquals(1, files.size());
                        assertEquals(new Path("/t", EnumSet.of(Path.Type.directory)), new ArrayList<>(files.keySet()).get(0));
                    }

                    @Override
                    public boolean isRecursive() {
                        return true;
                    }
                };
            }
            return super._getFeature(type);
        }

        @Override
        public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
            if (file.equals(new Path("/t", EnumSet.of(Path.Type.directory)))) {
                return new AttributedList<Path>(Arrays.asList(new Path("/t/a", EnumSet.of(Path.Type.file)), new Path("/t/d", EnumSet.of(Path.Type.directory))));
            }
            if (file.equals(new Path("/t/d", EnumSet.of(Path.Type.directory)))) {
                return new AttributedList<Path>(Collections.singletonList(new Path("/t/d/b", EnumSet.of(Path.Type.file))));
            }
            fail();
            return null;
        }
    };
    final DeleteWorker worker = new DeleteWorker(new DisabledLoginCallback(), Arrays.asList(new Path("/t", EnumSet.of(Path.Type.directory)), new Path("/t/a", EnumSet.of(Path.Type.file)), new Path("/t/d", EnumSet.of(Path.Type.directory)), new Path("/t/d", EnumSet.of(Path.Type.directory)), new Path("/t/d/b", EnumSet.of(Path.Type.file))), PathCache.empty(), new DisabledProgressListener());
    assertEquals(1, worker.run(session).size());
}
Also used : Delete(ch.cyberduck.core.features.Delete) AbstractPath(ch.cyberduck.core.AbstractPath) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) PasswordCallback(ch.cyberduck.core.PasswordCallback) AttributedList(ch.cyberduck.core.AttributedList) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) PasswordCallback(ch.cyberduck.core.PasswordCallback) ListProgressListener(ch.cyberduck.core.ListProgressListener) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 85 with NullSession

use of ch.cyberduck.core.NullSession in project cyberduck by iterate-ch.

the class DeleteWorkerTest method testSymlink.

@Test
public void testSymlink() throws Exception {
    final Session session = new NullSession(new Host(new TestProtocol())) {

        @Override
        @SuppressWarnings("unchecked")
        public <T> T _getFeature(final Class<T> type) {
            if (type == Delete.class) {
                return (T) new Delete() {

                    @Override
                    public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) {
                        assertEquals(new Path("/s", EnumSet.of(Path.Type.directory, AbstractPath.Type.symboliclink)), new ArrayList<>(files.keySet()).get(0));
                    }

                    @Override
                    public boolean isRecursive() {
                        return false;
                    }
                };
            }
            return super._getFeature(type);
        }

        @Override
        public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
            fail();
            return null;
        }
    };
    final DeleteWorker worker = new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(new Path("/s", EnumSet.of(Path.Type.directory, AbstractPath.Type.symboliclink))), PathCache.empty(), new DisabledProgressListener());
    worker.run(session);
}
Also used : Delete(ch.cyberduck.core.features.Delete) AbstractPath(ch.cyberduck.core.AbstractPath) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) PasswordCallback(ch.cyberduck.core.PasswordCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) PasswordCallback(ch.cyberduck.core.PasswordCallback) ListProgressListener(ch.cyberduck.core.ListProgressListener) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Aggregations

Host (ch.cyberduck.core.Host)128 NullSession (ch.cyberduck.core.NullSession)128 TestProtocol (ch.cyberduck.core.TestProtocol)128 Test (org.junit.Test)127 Path (ch.cyberduck.core.Path)118 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)81 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)69 NullLocal (ch.cyberduck.core.NullLocal)59 ListProgressListener (ch.cyberduck.core.ListProgressListener)40 AttributedList (ch.cyberduck.core.AttributedList)32 DisabledUploadSymlinkResolver (ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver)27 Local (ch.cyberduck.core.Local)24 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)24 ConnectionCallback (ch.cyberduck.core.ConnectionCallback)19 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)18 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)17 Session (ch.cyberduck.core.Session)17 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)17 HashMap (java.util.HashMap)14 LocalAttributes (ch.cyberduck.core.LocalAttributes)13