Search in sources :

Example 91 with DisabledProgressListener

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

the class OneDriveMeContextLoginTest method setup.

@Before
public void setup() throws Exception {
    final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new OneDriveProtocol())));
    final Profile profile = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/Microsoft OneDrive.cyberduckprofile"));
    final Host host = new Host(profile, profile.getDefaultHostname(), new Credentials("cyberduck"));
    session = new OneDriveSession(host, new DefaultX509TrustManager(), new DefaultX509KeyManager());
    final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) {
            fail(reason);
            return null;
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore() {

        @Override
        public String getPassword(Scheme scheme, int port, String hostname, String user) {
            if (user.endsWith("Microsoft OneDrive (cyberduck) OAuth2 Access Token")) {
                return System.getProperties().getProperty("onedrive.accesstoken");
            }
            if (user.endsWith("Microsoft OneDrive (cyberduck) OAuth2 Refresh Token")) {
                return System.getProperties().getProperty("onedrive.refreshtoken");
            }
            return null;
        }

        @Override
        public String getPassword(String hostname, String user) {
            return super.getPassword(hostname, user);
        }
    }, new DisabledProgressListener());
    login.check(session, new DisabledCancelCallback());
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) Scheme(ch.cyberduck.core.Scheme) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) Host(ch.cyberduck.core.Host) ProfilePlistReader(ch.cyberduck.core.serializer.impl.dd.ProfilePlistReader) Profile(ch.cyberduck.core.Profile) ProtocolFactory(ch.cyberduck.core.ProtocolFactory) LoginOptions(ch.cyberduck.core.LoginOptions) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) Credentials(ch.cyberduck.core.Credentials) DefaultX509TrustManager(ch.cyberduck.core.ssl.DefaultX509TrustManager) Before(org.junit.Before)

Example 92 with DisabledProgressListener

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

the class SpectraSingleTransferWorkerTest method testTransferredSizeRepeat.

@Ignore
@Test(expected = ConflictException.class)
public void testTransferredSizeRepeat() throws Exception {
    final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
    final byte[] content = new byte[98305];
    new Random().nextBytes(content);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(content, out);
    out.close();
    final Host host = new Host(new SpectraProtocol() {

        @Override
        public Scheme getScheme() {
            return Scheme.http;
        }
    }, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
    final BytecountStreamListener counter = new BytecountStreamListener();
    final AtomicBoolean failed = new AtomicBoolean();
    final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager()) {

        final SpectraWriteFeature write = new SpectraWriteFeature(this) {

            @Override
            public HttpResponseOutputStream<StorageObject> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
                final HttpResponseOutputStream<StorageObject> proxy = super.write(file, status, callback);
                if (failed.get()) {
                    // Second attempt successful
                    return proxy;
                }
                return new HttpResponseOutputStream<StorageObject>(new CountingOutputStream(proxy) {

                    @Override
                    protected void afterWrite(final int n) throws IOException {
                        super.afterWrite(n);
                        if (this.getByteCount() >= 42768L) {
                            assertTrue(this.getByteCount() < content.length);
                            // Buffer size
                            assertEquals(32768L, counter.getSent());
                            failed.set(true);
                            throw new SocketTimeoutException();
                        }
                    }
                }, new S3AttributesAdapter(), status) {

                    @Override
                    public StorageObject getStatus() throws BackgroundException {
                        return proxy.getStatus();
                    }

                    @Override
                    public void close() throws IOException {
                        super.close();
                        proxy.close();
                    }
                };
            }
        };

        @Override
        @SuppressWarnings("unchecked")
        public <T> T _getFeature(final Class<T> type) {
            if (type == Write.class) {
                return (T) write;
            }
            if (type == Upload.class) {
                return (T) new SpectraUploadFeature(this, write, new SpectraBulkService(this));
            }
            return super._getFeature(type);
        }
    };
    session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
    session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Transfer t = new UploadTransfer(session.getHost(), test, local);
    assertTrue(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(), counter, new DisabledLoginCallback(), new DisabledNotificationService()) {
    }.run(session));
    local.delete();
    assertTrue(t.isComplete());
    assertEquals(content.length, counter.getSent(), 0L);
    assertTrue(failed.get());
    assertEquals(content.length, new SpectraAttributesFinderFeature(session).find(test).getSize());
    new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) SpectraAttributesFinderFeature(ch.cyberduck.core.spectra.SpectraAttributesFinderFeature) Scheme(ch.cyberduck.core.Scheme) HttpResponseOutputStream(ch.cyberduck.core.http.HttpResponseOutputStream) OutputStream(java.io.OutputStream) CountingOutputStream(org.apache.commons.io.output.CountingOutputStream) SpectraBulkService(ch.cyberduck.core.spectra.SpectraBulkService) CountingOutputStream(org.apache.commons.io.output.CountingOutputStream) Random(java.util.Random) S3AttributesAdapter(ch.cyberduck.core.s3.S3AttributesAdapter) SpectraProtocol(ch.cyberduck.core.spectra.SpectraProtocol) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) S3DefaultDeleteFeature(ch.cyberduck.core.s3.S3DefaultDeleteFeature) Local(ch.cyberduck.core.Local) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SocketTimeoutException(java.net.SocketTimeoutException) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) HttpResponseOutputStream(ch.cyberduck.core.http.HttpResponseOutputStream) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) TransferItem(ch.cyberduck.core.transfer.TransferItem) BackgroundException(ch.cyberduck.core.exception.BackgroundException) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) SpectraWriteFeature(ch.cyberduck.core.spectra.SpectraWriteFeature) TransferAction(ch.cyberduck.core.transfer.TransferAction) SpectraUploadFeature(ch.cyberduck.core.spectra.SpectraUploadFeature) SpectraSession(ch.cyberduck.core.spectra.SpectraSession) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) StorageObject(org.jets3t.service.model.StorageObject) Host(ch.cyberduck.core.Host) IOException(java.io.IOException) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) ConnectionCallback(ch.cyberduck.core.ConnectionCallback) Credentials(ch.cyberduck.core.Credentials) Ignore(org.junit.Ignore) IntegrationTest(ch.cyberduck.test.IntegrationTest) Test(org.junit.Test)

Example 93 with DisabledProgressListener

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

the class SpectraBulkServiceTest method testPreDownloadFolderOnly.

@Test
public void testPreDownloadFolderOnly() throws Exception {
    final Host host = new Host(new SpectraProtocol() {

        @Override
        public Scheme getScheme() {
            return Scheme.http;
        }
    }, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
    final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
        // 
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    service.connect(session, new DisabledCancelCallback());
    final Set<UUID> keys = new SpectraBulkService(session).pre(Transfer.Type.download, Collections.singletonMap(new TransferItem(new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory))), new TransferStatus()), new DisabledConnectionCallback());
    assertTrue(keys.isEmpty());
    session.close();
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) Path(ch.cyberduck.core.Path) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) Scheme(ch.cyberduck.core.Scheme) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) Host(ch.cyberduck.core.Host) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) UUID(java.util.UUID) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) TransferItem(ch.cyberduck.core.transfer.TransferItem) Credentials(ch.cyberduck.core.Credentials) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 94 with DisabledProgressListener

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

the class SpectraBulkServiceTest method testPreDownloadNotFound.

@Test(expected = NotfoundException.class)
public void testPreDownloadNotFound() throws Exception {
    final Host host = new Host(new SpectraProtocol() {

        @Override
        public Scheme getScheme() {
            return Scheme.http;
        }
    }, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
    final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
        // 
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    service.connect(session, new DisabledCancelCallback());
    new SpectraBulkService(session).pre(Transfer.Type.download, Collections.singletonMap(new TransferItem(new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file))), new TransferStatus().withLength(1L)), new DisabledConnectionCallback());
    session.close();
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) Path(ch.cyberduck.core.Path) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) Scheme(ch.cyberduck.core.Scheme) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) Host(ch.cyberduck.core.Host) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) TransferItem(ch.cyberduck.core.transfer.TransferItem) Credentials(ch.cyberduck.core.Credentials) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 95 with DisabledProgressListener

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

the class SpectraBulkServiceTest method testPreUploadSingleFile.

@Test
public void testPreUploadSingleFile() throws Exception {
    final Host host = new Host(new SpectraProtocol() {

        @Override
        public Scheme getScheme() {
            return Scheme.http;
        }
    }, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
    final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
        // 
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    service.connect(session, new DisabledCancelCallback());
    final Map<TransferItem, TransferStatus> files = new HashMap<>();
    final TransferStatus status = new TransferStatus();
    final Path file = new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file));
    files.put(new TransferItem(file), status.withLength(1L));
    final SpectraBulkService bulk = new SpectraBulkService(session);
    bulk.pre(Transfer.Type.upload, files, new DisabledConnectionCallback());
    assertFalse(status.getParameters().isEmpty());
    assertNotNull(status.getParameters().get("job"));
    bulk.query(Transfer.Type.upload, file, status);
    new SpectraDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
Also used : Delete(ch.cyberduck.core.features.Delete) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) Scheme(ch.cyberduck.core.Scheme) HashMap(java.util.HashMap) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) Path(ch.cyberduck.core.Path) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) Host(ch.cyberduck.core.Host) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) TransferItem(ch.cyberduck.core.transfer.TransferItem) Credentials(ch.cyberduck.core.Credentials) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)166 Test (org.junit.Test)147 Host (ch.cyberduck.core.Host)135 Path (ch.cyberduck.core.Path)128 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)103 TestProtocol (ch.cyberduck.core.TestProtocol)95 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)94 NullSession (ch.cyberduck.core.NullSession)68 IntegrationTest (ch.cyberduck.test.IntegrationTest)65 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)59 NullLocal (ch.cyberduck.core.NullLocal)49 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)48 DisabledCancelCallback (ch.cyberduck.core.DisabledCancelCallback)48 DisabledHostKeyCallback (ch.cyberduck.core.DisabledHostKeyCallback)48 Credentials (ch.cyberduck.core.Credentials)43 Delete (ch.cyberduck.core.features.Delete)42 Local (ch.cyberduck.core.Local)40 LoginConnectionService (ch.cyberduck.core.LoginConnectionService)39 DefaultX509KeyManager (ch.cyberduck.core.ssl.DefaultX509KeyManager)36 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)34