Search in sources :

Example 51 with TestProtocol

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

the class OpenSSHCredentialsConfiguratorTest method testNoConfigure.

@Test
public void testNoConfigure() {
    OpenSSHCredentialsConfigurator c = new OpenSSHCredentialsConfigurator(new OpenSshConfig(new Local("src/main/test/resources", "openssh/config")));
    Credentials credentials = new Credentials("user", " ");
    credentials.setIdentity(new NullLocal("t"));
    assertEquals("t", c.configure(new Host(new TestProtocol(Scheme.sftp), "t", credentials)).getIdentity().getName());
}
Also used : TestProtocol(ch.cyberduck.core.TestProtocol) OpenSshConfig(ch.cyberduck.core.sftp.openssh.config.transport.OpenSshConfig) NullLocal(ch.cyberduck.core.NullLocal) NullLocal(ch.cyberduck.core.NullLocal) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) Credentials(ch.cyberduck.core.Credentials) Test(org.junit.Test)

Example 52 with TestProtocol

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

the class AzureSingleTransferWorkerTest method download.

private void download(final Host host) throws ch.cyberduck.core.exception.BackgroundException, java.io.IOException {
    final OperationContext context = new OperationContext();
    final AzureSession session = new AzureSession(host);
    session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
    session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path test = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local localFile = TemporaryFileServiceFactory.get().create(test.getName());
    {
        final byte[] content = RandomUtils.nextBytes(39864);
        final TransferStatus writeStatus = new TransferStatus().withLength(content.length).withChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()));
        final StatusOutputStream out = new AzureWriteFeature(session, context).write(test, writeStatus, new DisabledConnectionCallback());
        assertNotNull(out);
        new StreamCopier(writeStatus, writeStatus).withLimit((long) content.length).transfer(new ByteArrayInputStream(content), out);
        out.close();
    }
    final byte[] content = RandomUtils.nextBytes(39864);
    final TransferStatus writeStatus = new TransferStatus().withLength(content.length).withChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()));
    final StatusOutputStream<Void> out = new AzureWriteFeature(session, context).write(test, writeStatus, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(writeStatus, writeStatus).withLimit((long) content.length).transfer(new ByteArrayInputStream(content), out);
    out.close();
    final Transfer t = new DownloadTransfer(new Host(new TestProtocol()), Collections.singletonList(new TransferItem(test, localFile)), 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));
    assertArrayEquals(content, IOUtils.toByteArray(localFile.getInputStream()));
    new AzureDeleteFeature(session, context).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    localFile.delete();
}
Also used : Delete(ch.cyberduck.core.features.Delete) TestProtocol(ch.cyberduck.core.TestProtocol) TransferAction(ch.cyberduck.core.transfer.TransferAction) AzureWriteFeature(ch.cyberduck.core.azure.AzureWriteFeature) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) OperationContext(com.microsoft.azure.storage.OperationContext) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) AzureSession(ch.cyberduck.core.azure.AzureSession) StatusOutputStream(ch.cyberduck.core.io.StatusOutputStream) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) ByteArrayInputStream(java.io.ByteArrayInputStream) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AzureDeleteFeature(ch.cyberduck.core.azure.AzureDeleteFeature) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) TransferItem(ch.cyberduck.core.transfer.TransferItem) SHA256ChecksumCompute(ch.cyberduck.core.io.SHA256ChecksumCompute) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier)

Example 53 with TestProtocol

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

the class TerminalStreamListenerTest method testSent.

@Test
public void testSent() {
    final DownloadTransfer transfer = new DownloadTransfer(new Host(new TestProtocol()), Collections.<TransferItem>emptyList());
    final TerminalStreamListener l = new TerminalStreamListener(new TransferSpeedometer(transfer));
    l.sent(1L);
    transfer.addSize(1L);
    l.sent(1L);
}
Also used : TestProtocol(ch.cyberduck.core.TestProtocol) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) Host(ch.cyberduck.core.Host) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) Test(org.junit.Test)

Example 54 with TestProtocol

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

the class SystemConfigurationReachabilityTest method testMonitor.

@Test
public void testMonitor() {
    final Reachability r = new SystemConfigurationReachability();
    final Reachability.Monitor monitor = r.monitor(new Host(new TestProtocol(), "cyberduck.ch", 80), new Reachability.Callback() {

        @Override
        public void change() {
        }
    }).start();
    assertSame(monitor, monitor.stop());
}
Also used : TestProtocol(ch.cyberduck.core.TestProtocol) Host(ch.cyberduck.core.Host) Test(org.junit.Test)

Example 55 with TestProtocol

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

the class SystemConfigurationReachabilityTest method testIsReachablePort22.

@Test
public void testIsReachablePort22() {
    final Reachability r = new SystemConfigurationReachability();
    assertTrue(r.isReachable(new Host(new TestProtocol(), "cyberduck.ch", 22)));
}
Also used : TestProtocol(ch.cyberduck.core.TestProtocol) Host(ch.cyberduck.core.Host) Test(org.junit.Test)

Aggregations

TestProtocol (ch.cyberduck.core.TestProtocol)253 Test (org.junit.Test)251 Host (ch.cyberduck.core.Host)230 Path (ch.cyberduck.core.Path)173 NullSession (ch.cyberduck.core.NullSession)131 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)107 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)96 Local (ch.cyberduck.core.Local)79 NullLocal (ch.cyberduck.core.NullLocal)76 ListProgressListener (ch.cyberduck.core.ListProgressListener)44 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)35 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)34 AttributedList (ch.cyberduck.core.AttributedList)33 ProtocolFactory (ch.cyberduck.core.ProtocolFactory)29 Transfer (ch.cyberduck.core.transfer.Transfer)28 DisabledUploadSymlinkResolver (ch.cyberduck.core.transfer.symlink.DisabledUploadSymlinkResolver)28 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)27 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)27 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)27 UploadTransfer (ch.cyberduck.core.transfer.UploadTransfer)25