BAEL-4465 (#9954)
* initial commit * fixed indent * removed unused dependencies * some minor code changes and unit tests * fixed file names
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.baeldung.ssh;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.ssh.apachesshd.SshdDemo;
|
||||
|
||||
public class ApacheMinaSshdLiveTest {
|
||||
|
||||
@Test
|
||||
public void givenValidCredentials_whenConnectionIsEstablished_thenServerReturnsResponse() throws Exception {
|
||||
String username = "demo";
|
||||
String password = "password";
|
||||
String host = "test.rebex.net";
|
||||
int port = 22;
|
||||
long defaultTimeoutSeconds = 10l;
|
||||
String command = "ls\n";
|
||||
String responseString = SshdDemo.listFolderStructure(username, password, host, port, defaultTimeoutSeconds, command);
|
||||
|
||||
assertNotNull(responseString);
|
||||
}
|
||||
|
||||
@Test(expected = Exception.class)
|
||||
public void givenInvalidCredentials_whenConnectionAttemptIsMade_thenServerReturnsErrorResponse() throws Exception {
|
||||
String username = "invalidUsername";
|
||||
String password = "password";
|
||||
String host = "test.rebex.net";
|
||||
int port = 22;
|
||||
long defaultTimeoutSeconds = 10l;
|
||||
String command = "ls\n";
|
||||
String responseString = SshdDemo.listFolderStructure(username, password, host, port, defaultTimeoutSeconds, command);
|
||||
|
||||
assertNull(responseString);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.baeldung.ssh;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.ssh.jsch.JschDemo;
|
||||
|
||||
public class JSchLiveTest {
|
||||
|
||||
@Test
|
||||
public void givenValidCredentials_whenConnectionIsEstablished_thenServerReturnsResponse() throws Exception {
|
||||
String username = "demo";
|
||||
String password = "password";
|
||||
String host = "test.rebex.net";
|
||||
int port = 22;
|
||||
String command = "ls";
|
||||
String responseString = JschDemo.listFolderStructure(username, password, host, port, command);
|
||||
|
||||
assertNotNull(responseString);
|
||||
}
|
||||
|
||||
@Test(expected = Exception.class)
|
||||
public void givenInvalidCredentials_whenConnectionAttemptIsMade_thenServerReturnsErrorResponse() throws Exception {
|
||||
String username = "invalidUsername";
|
||||
String password = "password";
|
||||
String host = "test.rebex.net";
|
||||
int port = 22;
|
||||
String command = "ls";
|
||||
String responseString = JschDemo.listFolderStructure(username, password, host, port, command);
|
||||
|
||||
assertNull(responseString);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user