Search in sources :

Example 41 with DisabledNotificationService

use of ch.cyberduck.core.notification.DisabledNotificationService in project cyberduck by iterate-ch.

the class ConcurrentTransferWorkerTest method testBorrow.

@Test
public void testBorrow() throws Exception {
    final Host host = new Host(new TestProtocol(), "test.cyberduck.ch");
    final Transfer t = new UploadTransfer(host, new Path("/t", EnumSet.of(Path.Type.directory)), new NullLocal("l"));
    final LoginConnectionService connection = new TestLoginConnectionService();
    final DefaultSessionPool pool = new DefaultSessionPool(connection, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), host);
    final ConcurrentTransferWorker worker = new ConcurrentTransferWorker(pool, SessionPool.DISCONNECTED, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt(), new DisabledTransferErrorCallback(), new DisabledLoginCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledNotificationService());
    assertNotSame(worker.borrow(ConcurrentTransferWorker.Connection.source), worker.borrow(ConcurrentTransferWorker.Connection.source));
    worker.cleanup(true);
}
Also used : DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) Test(org.junit.Test)

Example 42 with DisabledNotificationService

use of ch.cyberduck.core.notification.DisabledNotificationService in project cyberduck by iterate-ch.

the class ConcurrentTransferWorkerTest method testSessionReuse.

@Test
public void testSessionReuse() throws Exception {
    final Host host = new Host(new TestProtocol(), "test.cyberduck.ch");
    final Transfer t = new UploadTransfer(host, new Path("/t", EnumSet.of(Path.Type.directory)), new NullLocal("l"));
    final LoginConnectionService connection = new TestLoginConnectionService();
    final DefaultSessionPool pool = new DefaultSessionPool(connection, new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), host);
    final ConcurrentTransferWorker worker = new ConcurrentTransferWorker(pool.withMaxTotal(1), SessionPool.DISCONNECTED, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt(), new DisabledTransferErrorCallback(), new DisabledLoginCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledNotificationService());
    // Override default transfer queue size
    pool.withMaxTotal(1);
    final Session<?> session = worker.borrow(ConcurrentTransferWorker.Connection.source);
    worker.release(session, ConcurrentTransferWorker.Connection.source, null);
    assertEquals(Session.State.closed, session.getState());
    final Session<?> reuse = worker.borrow(ConcurrentTransferWorker.Connection.source);
    assertSame(session, reuse);
    final CyclicBarrier lock = new CyclicBarrier(2);
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                assertSame(session, worker.borrow(ConcurrentTransferWorker.Connection.source));
                try {
                    lock.await(1, TimeUnit.MINUTES);
                } catch (InterruptedException | BrokenBarrierException | TimeoutException e) {
                    fail();
                }
            } catch (BackgroundException e) {
                fail();
            }
        }
    }).start();
    worker.release(reuse, ConcurrentTransferWorker.Connection.source, null);
    lock.await(1, TimeUnit.MINUTES);
    worker.cleanup(true);
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) TimeoutException(java.util.concurrent.TimeoutException) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) CyclicBarrier(java.util.concurrent.CyclicBarrier) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) BackgroundException(ch.cyberduck.core.exception.BackgroundException) Test(org.junit.Test)

Example 43 with DisabledNotificationService

use of ch.cyberduck.core.notification.DisabledNotificationService in project cyberduck by iterate-ch.

the class FTPConcurrentTransferWorkerTest method testConcurrentSessions.

@Test
public void testConcurrentSessions() throws Exception {
    final int files = 20;
    final int connections = 2;
    final List<TransferItem> list = new ArrayList<>();
    final Local file = new Local(File.createTempFile(new AlphanumericRandomStringService().random(), "t").getAbsolutePath());
    for (int i = 1; i <= files; i++) {
        list.add(new TransferItem(new Path(String.format("/t%d", i), EnumSet.of(Path.Type.file)), file));
    }
    final Transfer transfer = new UploadTransfer(session.getHost(), list);
    final DefaultSessionPool pool = new DefaultSessionPool(new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) {
            return new Credentials(username, "test");
        }

        @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()), new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DefaultVaultRegistry(new DisabledPasswordCallback()), new DisabledTranscriptListener(), session.getHost());
    final ConcurrentTransferWorker worker = new ConcurrentTransferWorker(pool.withMaxTotal(connections), SessionPool.DISCONNECTED, transfer, new TransferOptions(), new TransferSpeedometer(transfer), new DisabledTransferPrompt() {

        @Override
        public TransferAction prompt(final TransferItem file) {
            return TransferAction.overwrite;
        }
    }, new DisabledTransferErrorCallback(), new DisabledLoginCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledNotificationService());
    pool.withMaxTotal(connections);
    final Session<?> session = worker.borrow(ConcurrentTransferWorker.Connection.source);
    assertTrue(worker.run(session));
    worker.release(session, ConcurrentTransferWorker.Connection.source, null);
    assertEquals(0L, transfer.getTransferred(), 0L);
    worker.cleanup(true);
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) TransferAction(ch.cyberduck.core.transfer.TransferAction) ArrayList(java.util.ArrayList) DefaultSessionPool(ch.cyberduck.core.pool.DefaultSessionPool) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) TransferItem(ch.cyberduck.core.transfer.TransferItem) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Test(org.junit.Test) AbstractFTPTest(ch.cyberduck.core.ftp.AbstractFTPTest)

Example 44 with DisabledNotificationService

use of ch.cyberduck.core.notification.DisabledNotificationService in project cyberduck by iterate-ch.

the class CryptoAzureSingleTransferWorkerTest method testUpload.

@Test
public void testUpload() throws Exception {
    final Path home = new Path("cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory));
    final CryptoVault cryptomator = new CryptoVault(new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)));
    final Path vault = cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final Path dir1 = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.placeholder));
    final Local localDirectory1 = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
    new DefaultLocalDirectoryFeature().mkdir(localDirectory1);
    final byte[] content = RandomUtils.nextBytes(62768);
    final Path file1 = new Path(dir1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local localFile1 = new Local(localDirectory1, file1.getName());
    final OutputStream out1 = localFile1.getOutputStream(false);
    IOUtils.write(content, out1);
    out1.close();
    final Path file2 = new Path(dir1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local localFile2 = new Local(localDirectory1, file2.getName());
    final OutputStream out2 = localFile2.getOutputStream(false);
    IOUtils.write(content, out2);
    out2.close();
    final Transfer t = new UploadTransfer(new Host(new TestProtocol()), Collections.singletonList(new TransferItem(dir1, localDirectory1)), new NullFilter<>());
    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(), new DisabledStreamListener(), new DisabledLoginCallback(), new DisabledNotificationService()) {
    }.run(session));
    assertTrue(new CryptoFindFeature(session, new AzureFindFeature(session, null), cryptomator).find(dir1));
    assertEquals(content.length, new CryptoAttributesFeature(session, new AzureAttributesFinderFeature(session, null), cryptomator).find(file1).getSize());
    {
        final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
        final InputStream in = new CryptoReadFeature(session, new AzureReadFeature(session, null), cryptomator).read(file1, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
        new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer);
        assertArrayEquals(content, buffer.toByteArray());
    }
    assertEquals(content.length, new CryptoAttributesFeature(session, new AzureAttributesFinderFeature(session, null), cryptomator).find(file2).getSize());
    {
        final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
        final InputStream in = new CryptoReadFeature(session, new AzureReadFeature(session, null), cryptomator).read(file1, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
        new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer);
        assertArrayEquals(content, buffer.toByteArray());
    }
    cryptomator.getFeature(session, Delete.class, new AzureDeleteFeature(session, null)).delete(Arrays.asList(file1, file2, dir1, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    localFile1.delete();
    localFile2.delete();
    localDirectory1.delete();
}
Also used : Delete(ch.cyberduck.core.features.Delete) TestProtocol(ch.cyberduck.core.TestProtocol) TransferAction(ch.cyberduck.core.transfer.TransferAction) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) SingleTransferWorker(ch.cyberduck.core.worker.SingleTransferWorker) AzureFindFeature(ch.cyberduck.core.azure.AzureFindFeature) AzureAttributesFinderFeature(ch.cyberduck.core.azure.AzureAttributesFinderFeature) AzureReadFeature(ch.cyberduck.core.azure.AzureReadFeature) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultLocalDirectoryFeature(ch.cyberduck.core.local.DefaultLocalDirectoryFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) CryptoReadFeature(ch.cyberduck.core.cryptomator.features.CryptoReadFeature) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) InputStream(java.io.InputStream) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AzureDeleteFeature(ch.cyberduck.core.azure.AzureDeleteFeature) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) TransferItem(ch.cyberduck.core.transfer.TransferItem) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractAzureTest(ch.cyberduck.core.azure.AbstractAzureTest) Test(org.junit.Test)

Example 45 with DisabledNotificationService

use of ch.cyberduck.core.notification.DisabledNotificationService in project cyberduck by iterate-ch.

the class B2SingleTransferWorkerTest method testTransferredSizeRepeat.

@Test
public void testTransferredSizeRepeat() throws Exception {
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] content = new byte[100 * 1024 * 1024 + 1];
    new Random().nextBytes(content);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(content, out);
    out.close();
    final AtomicBoolean failed = new AtomicBoolean();
    final B2Session custom = new B2Session(session.getHost().withCredentials(new Credentials(System.getProperties().getProperty("b2.user"), System.getProperties().getProperty("b2.key"))), new DefaultX509TrustManager(), new DefaultX509KeyManager()) {

        final B2LargeUploadService upload = new B2LargeUploadService(this, new B2VersionIdProvider(this), new B2WriteFeature(this, new B2VersionIdProvider(this)), PreferencesFactory.get().getLong("b2.upload.largeobject.size"), PreferencesFactory.get().getInteger("b2.upload.largeobject.concurrency")) {

            @Override
            protected InputStream decorate(final InputStream in, final MessageDigest digest) {
                if (failed.get()) {
                    // Second attempt successful
                    return in;
                }
                return new CountingInputStream(in) {

                    @Override
                    protected void beforeRead(final int n) throws IOException {
                        super.beforeRead(n);
                        if (this.getByteCount() >= 100L * 1024L * 1024L) {
                            failed.set(true);
                            throw new SocketTimeoutException();
                        }
                    }
                };
            }
        };

        @Override
        @SuppressWarnings("unchecked")
        public <T> T _getFeature(final Class<T> type) {
            if (type == Upload.class) {
                return (T) upload;
            }
            return super._getFeature(type);
        }
    };
    custom.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
    custom.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path test = new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final Transfer t = new UploadTransfer(session.getHost(), test, local);
    final BytecountStreamListener counter = new BytecountStreamListener();
    assertTrue(new SingleTransferWorker(custom, custom, 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(custom));
    local.delete();
    assertTrue(t.isComplete());
    final B2VersionIdProvider fileid = new B2VersionIdProvider(custom);
    assertEquals(content.length, new B2AttributesFinderFeature(custom, fileid).find(test).getSize());
    assertEquals(content.length, counter.getRecv(), 0L);
    assertEquals(content.length, counter.getSent(), 0L);
    assertTrue(failed.get());
    new B2DeleteFeature(custom, fileid).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) TransferAction(ch.cyberduck.core.transfer.TransferAction) OutputStream(java.io.OutputStream) B2VersionIdProvider(ch.cyberduck.core.b2.B2VersionIdProvider) B2AttributesFinderFeature(ch.cyberduck.core.b2.B2AttributesFinderFeature) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) Random(java.util.Random) B2DeleteFeature(ch.cyberduck.core.b2.B2DeleteFeature) MessageDigest(java.security.MessageDigest) B2LargeUploadService(ch.cyberduck.core.b2.B2LargeUploadService) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) CountingInputStream(org.apache.commons.io.input.CountingInputStream) InputStream(java.io.InputStream) B2WriteFeature(ch.cyberduck.core.b2.B2WriteFeature) CountingInputStream(org.apache.commons.io.input.CountingInputStream) Local(ch.cyberduck.core.Local) IOException(java.io.IOException) B2Session(ch.cyberduck.core.b2.B2Session) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) 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) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) TransferItem(ch.cyberduck.core.transfer.TransferItem) Credentials(ch.cyberduck.core.Credentials) DefaultX509TrustManager(ch.cyberduck.core.ssl.DefaultX509TrustManager) AbstractB2Test(ch.cyberduck.core.b2.AbstractB2Test) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

DisabledNotificationService (ch.cyberduck.core.notification.DisabledNotificationService)45 Test (org.junit.Test)44 DisabledTransferErrorCallback (ch.cyberduck.core.transfer.DisabledTransferErrorCallback)37 DisabledTransferPrompt (ch.cyberduck.core.transfer.DisabledTransferPrompt)37 Transfer (ch.cyberduck.core.transfer.Transfer)37 TransferOptions (ch.cyberduck.core.transfer.TransferOptions)37 TransferSpeedometer (ch.cyberduck.core.transfer.TransferSpeedometer)37 DisabledStreamListener (ch.cyberduck.core.io.DisabledStreamListener)36 UploadTransfer (ch.cyberduck.core.transfer.UploadTransfer)35 TransferItem (ch.cyberduck.core.transfer.TransferItem)32 TransferAction (ch.cyberduck.core.transfer.TransferAction)31 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)27 Delete (ch.cyberduck.core.features.Delete)26 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)25 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)25 Path (ch.cyberduck.core.Path)25 Local (ch.cyberduck.core.Local)23 IntegrationTest (ch.cyberduck.test.IntegrationTest)23 Host (ch.cyberduck.core.Host)21 DownloadTransfer (ch.cyberduck.core.transfer.DownloadTransfer)21