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());
}
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();
}
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);
}
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());
}
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)));
}
Aggregations