Search in sources :

Example 6 with SshClient

use of org.apache.sshd.SshClient in project fabric8 by jboss-fuse.

the class ContainerConnectAction method createClient.

protected SshClient createClient() {
    // must create a new client for each usage
    SshClient client = SshClient.setUpDefaultClient();
    client.setAgentFactory(agentFactory);
    // must start client
    client.start();
    log.trace("Created SshClient: {}", client);
    return client;
}
Also used : SshClient(org.apache.sshd.SshClient)

Example 7 with SshClient

use of org.apache.sshd.SshClient in project ovirt-engine by oVirt.

the class TimeoutTest method testConnectTimeout.

@Test(expected = TimeLimitExceededException.class)
public void testConnectTimeout() throws Exception {
    SSHClient client = spy(this.client);
    SshClient ssh = spy(SshClient.setUpDefaultClient());
    ConnectFuture future = mock(ConnectFuture.class);
    doReturn(ssh).when(client).createSshClient();
    doReturn(future).when(ssh).connect(any(), anyInt());
    when(future.await(anyLong())).thenReturn(false);
    client.connect();
}
Also used : SshClient(org.apache.sshd.SshClient) ConnectFuture(org.apache.sshd.client.future.ConnectFuture) Test(org.junit.Test)

Aggregations

SshClient (org.apache.sshd.SshClient)7 ConnectFuture (org.apache.sshd.client.future.ConnectFuture)4 ClientSession (org.apache.sshd.ClientSession)3 Test (org.junit.Test)2 VaadinRequest (com.vaadin.server.VaadinRequest)1 UI (com.vaadin.ui.UI)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 FabricAuthenticationException (io.fabric8.api.FabricAuthenticationException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ClientChannel (org.apache.sshd.ClientChannel)1 ScpClient (org.apache.sshd.client.ScpClient)1 ChannelShell (org.apache.sshd.client.channel.ChannelShell)1 AuthFuture (org.apache.sshd.client.future.AuthFuture)1 NoCloseInputStream (org.apache.sshd.common.util.NoCloseInputStream)1 NoCloseOutputStream (org.apache.sshd.common.util.NoCloseOutputStream)1 Before (org.junit.Before)1 SshException (org.platformlayer.ops.ssh.SshException)1