2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 2018 TechMahindra
6 *=================================================================================
7 * Modifications Copyright 2019 IBM.
8 *=================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 package org.onap.appc.adapter.ssh;
24 import static org.junit.Assert.*;
26 import org.junit.Before;
27 import org.junit.Test;
29 public class TestSshConnectionMock {
31 private SshConnectionMock sshConnectionMock;
34 sshConnectionMock=new SshConnectionMock("localhost", 8080, "myUser", "myPassword", "sampleKeyFile");
38 public void testGetHost() {
39 assertEquals("localhost", sshConnectionMock.getHost());
43 public void testGetPort() {
44 assertEquals(8080, sshConnectionMock.getPort());
48 public void testGetUsername() {
49 assertEquals("myUser", sshConnectionMock.getUsername());
53 public void testGetPassword() {
54 assertEquals("myPassword", sshConnectionMock.getPassword());
58 public void testKeyFile() {
59 assertEquals("sampleKeyFile", sshConnectionMock.getKeyFile());
63 public void testGetReturnStderr() {
64 sshConnectionMock.setReturnStderr("returnStderr");
65 assertEquals("returnStderr", sshConnectionMock.getReturnStderr());
68 public void testGetReturnStdout() {
69 sshConnectionMock.setReturnStdout("returnStdout");
70 assertEquals("returnStdout", sshConnectionMock.getReturnStdout());
73 public void testGetReturnStatus() {
74 sshConnectionMock.setReturnStatus(200);
75 assertEquals(200, sshConnectionMock.getReturnStatus());
78 public void testGetExecutedCommands() {
79 sshConnectionMock.getExecutedCommands().add("cls");
80 sshConnectionMock.getExecutedCommands().add("pwd");
81 assertNotNull(sshConnectionMock.getExecutedCommands());
82 assertEquals(false, sshConnectionMock.getExecutedCommands().isEmpty());
86 public void testExecTimeout()
88 sshConnectionMock.setExecTimeout(20);
89 assertEquals(20,sshConnectionMock.getExecTimeout());