Search in sources :

Example 1 with NullSession

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

the class DefaultSessionPoolTest method testCheckReconnectApplicationFailure.

@Test
public void testCheckReconnectApplicationFailure() throws Exception {
    final AtomicBoolean interrupt = new AtomicBoolean();
    final Host bookmark = new Host(new TestProtocol());
    final TestLoginConnectionService connect = new TestLoginConnectionService() {

        @Override
        public boolean check(final Session<?> session, final CancelCallback callback) {
            return true;
        }
    };
    final DefaultSessionPool pool = new DefaultSessionPool(connect, new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), bookmark, new GenericObjectPool<Session>(new PooledSessionFactory(connect, new DisabledX509TrustManager(), new DefaultX509KeyManager(), bookmark, new DefaultVaultRegistry(new DisabledPasswordCallback())) {

        @Override
        public Session create() {
            return new NullSession(bookmark) {

                @Override
                public void interrupt() throws BackgroundException {
                    interrupt.set(true);
                    super.interrupt();
                }
            };
        }
    }));
    final Session<?> session = pool.borrow(BackgroundActionState.running);
    pool.release(session, new BackgroundException("m", "d"));
    assertFalse(interrupt.get());
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) CancelCallback(ch.cyberduck.core.threading.CancelCallback) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) BackgroundException(ch.cyberduck.core.exception.BackgroundException) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 2 with NullSession

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

the class DefaultSessionPoolTest method testCheckReconnectSocketFailure.

@Test
public void testCheckReconnectSocketFailure() throws Exception {
    final AtomicBoolean interrupt = new AtomicBoolean();
    final Host bookmark = new Host(new TestProtocol());
    final TestLoginConnectionService connect = new TestLoginConnectionService() {

        @Override
        public boolean check(final Session<?> session, final CancelCallback callback) {
            return true;
        }
    };
    final DefaultSessionPool pool = new DefaultSessionPool(connect, new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), bookmark, new GenericObjectPool<Session>(new PooledSessionFactory(connect, new DisabledX509TrustManager(), new DefaultX509KeyManager(), bookmark, new DefaultVaultRegistry(new DisabledPasswordCallback())) {

        @Override
        public Session create() {
            return new NullSession(bookmark) {

                @Override
                public void interrupt() throws BackgroundException {
                    interrupt.set(true);
                    super.interrupt();
                }
            };
        }
    }));
    final Session<?> session = pool.borrow(BackgroundActionState.running);
    pool.release(session, new BackgroundException("m", new SocketException("m")));
    assertTrue(interrupt.get());
}
Also used : SocketException(java.net.SocketException) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) CancelCallback(ch.cyberduck.core.threading.CancelCallback) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) BackgroundException(ch.cyberduck.core.exception.BackgroundException) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 3 with NullSession

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

the class StatelessSessionPoolTest method testCheckReconnectSocketFailure.

@Test
public void testCheckReconnectSocketFailure() throws Exception {
    final AtomicBoolean interrupt = new AtomicBoolean();
    final StatelessSessionPool pool = new StatelessSessionPool(new TestLoginConnectionService() {

        @Override
        public boolean check(final Session<?> session, final CancelCallback callback) {
            return true;
        }
    }, new NullSession(new Host(new TestProtocol())) {

        @Override
        public void interrupt() throws BackgroundException {
            interrupt.set(true);
            super.interrupt();
        }
    }, new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback()));
    final Session<?> session = pool.borrow(BackgroundActionState.running);
    pool.release(session, new BackgroundException("m", new SocketException("m")));
    assertFalse(interrupt.get());
}
Also used : SocketException(java.net.SocketException) TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) CancelCallback(ch.cyberduck.core.threading.CancelCallback) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) BackgroundException(ch.cyberduck.core.exception.BackgroundException) Test(org.junit.Test)

Example 4 with NullSession

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

the class RemoteProfilesFinderTest method find.

@Test
public void find() throws Exception {
    final ProtocolFactory protocols = new ProtocolFactory(new HashSet<>(Arrays.asList(new TestProtocol() {

        @Override
        public String getIdentifier() {
            return "s3";
        }

        @Override
        public Type getType() {
            return Type.s3;
        }

        @Override
        public boolean isEnabled() {
            return false;
        }
    }, new TestProtocol() {

        @Override
        public String getIdentifier() {
            return "davs";
        }

        @Override
        public Type getType() {
            return Type.dav;
        }

        @Override
        public boolean isEnabled() {
            return false;
        }
    })));
    final ProfilePlistReader reader = new ProfilePlistReader(protocols);
    final TestProtocol protocol = new TestProtocol() {

        @Override
        public String getIdentifier() {
            return "davs";
        }

        @Override
        public Scheme getScheme() {
            return Scheme.https;
        }

        @Override
        public Type getType() {
            return Type.dav;
        }

        @Override
        public boolean isEnabled() {
            return false;
        }
    };
    final Host host = new HostParser(protocols, protocol).get("https://svn.cyberduck.io/trunk/profiles");
    final NullSession session = new NullSession(host);
    session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final RemoteProfilesFinder finder = new RemoteProfilesFinder(session);
    final Set<ProfileDescription> stream = finder.find();
    assertTrue(stream.isEmpty());
    session.close();
}
Also used : TestProtocol(ch.cyberduck.core.TestProtocol) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) ProfilePlistReader(ch.cyberduck.core.serializer.impl.dd.ProfilePlistReader) ProtocolFactory(ch.cyberduck.core.ProtocolFactory) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) HostParser(ch.cyberduck.core.HostParser) Test(org.junit.Test)

Example 5 with NullSession

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

the class SingleTransferWorkerTest method testUploadPrepareOverrideRootDoesNotExist.

@Test
public void testUploadPrepareOverrideRootDoesNotExist() throws Exception {
    final Path child = new Path("/t/c", EnumSet.of(Path.Type.file));
    final Path root = new Path("/t", EnumSet.of(Path.Type.directory)) {

        @Override
        public Path getParent() {
            return new Path("/", EnumSet.of(Path.Type.directory));
        }
    };
    final NullLocal local = new NullLocal("l") {

        @Override
        public AttributedList<Local> list() {
            AttributedList<Local> l = new AttributedList<Local>();
            l.add(new NullLocal(this.getAbsolute(), "c") {

                @Override
                public boolean exists() {
                    return true;
                }
            });
            return l;
        }

        @Override
        public boolean exists() {
            return true;
        }
    };
    final Transfer t = new UploadTransfer(new Host(new TestProtocol()), root, local) {

        @Override
        public void transfer(final Session<?> source, final Session<?> destination, final Path file, Local local, final TransferOptions options, final TransferStatus overall, final TransferStatus segment, final ConnectionCallback connectionCallback, final ProgressListener listener, final StreamListener streamListener) {
        // 
        }
    };
    final NullSession session = new NullSession(new Host(new TestProtocol()));
    final SingleTransferWorker worker = new SingleTransferWorker(session, session, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() {

        @Override
        public TransferAction prompt(final TransferItem file) {
            return TransferAction.overwrite;
        }
    }, new DisabledTransferErrorCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledLoginCallback(), new DisabledNotificationService()) {

        @Override
        public Future<TransferStatus> transfer(final TransferItem item, final TransferAction action) throws BackgroundException {
            if (item.remote.equals(root)) {
                assertTrue(this.getCache().isCached(new TransferItem(root, local)));
            }
            super.transfer(new TransferItem(item.remote, new NullLocal("l") {

                @Override
                public AttributedList<Local> list() {
                    AttributedList<Local> l = new AttributedList<Local>();
                    l.add(new NullLocal(this.getAbsolute(), "c"));
                    return l;
                }
            }), action);
            assertFalse(this.getCache().isCached(new TransferItem(child, local)));
            return null;
        }
    };
    worker.run(session);
    assertFalse(worker.getCache().isCached(new TransferItem(child, local)));
}
Also used : TestProtocol(ch.cyberduck.core.TestProtocol) TransferAction(ch.cyberduck.core.transfer.TransferAction) NullSession(ch.cyberduck.core.NullSession) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) NullLocal(ch.cyberduck.core.NullLocal) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) StreamListener(ch.cyberduck.core.io.StreamListener) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) NullLocal(ch.cyberduck.core.NullLocal) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) AttributedList(ch.cyberduck.core.AttributedList) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) ListProgressListener(ch.cyberduck.core.ListProgressListener) ProgressListener(ch.cyberduck.core.ProgressListener) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) ConnectionCallback(ch.cyberduck.core.ConnectionCallback) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) TransferItem(ch.cyberduck.core.transfer.TransferItem) 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