2d157f12824ca9c17cf58cf1be073c8006e3ef25
[appc.git] / appc-adapters / appc-ssh-adapter / appc-ssh-adapter-tests / src / test / java / org / onap / appc / adapter / ssh / TestSshConnectionMock.java
1 /*
2 * ============LICENSE_START=======================================================
3 * ONAP : APPC
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
12 *
13 *     http://www.apache.org/licenses/LICENSE-2.0
14 *
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=========================================================
21 */
22 package org.onap.appc.adapter.ssh;
23
24 import static org.junit.Assert.*;
25
26 import org.junit.Before;
27 import org.junit.Test;
28
29 public class TestSshConnectionMock {
30
31     private SshConnectionMock sshConnectionMock;
32     @Before
33     public void setUp() {
34         sshConnectionMock=new SshConnectionMock("localhost", 8080, "myUser", "myPassword", "sampleKeyFile");
35     }
36     
37     @Test
38     public void testGetHost() {
39         assertEquals("localhost", sshConnectionMock.getHost());
40     }
41
42     @Test
43     public void testGetPort() {
44         assertEquals(8080, sshConnectionMock.getPort());
45     }
46
47     @Test
48     public void testGetUsername() {
49         assertEquals("myUser", sshConnectionMock.getUsername());
50     }
51
52     @Test
53     public void testGetPassword() {
54         assertEquals("myPassword", sshConnectionMock.getPassword());
55     }
56
57     @Test
58     public void testKeyFile() {
59         assertEquals("sampleKeyFile", sshConnectionMock.getKeyFile());
60     }
61
62     @Test
63     public void testGetReturnStderr() {
64         sshConnectionMock.setReturnStderr("returnStderr");
65         assertEquals("returnStderr", sshConnectionMock.getReturnStderr());
66     }
67     @Test
68     public void testGetReturnStdout() {
69         sshConnectionMock.setReturnStdout("returnStdout");
70         assertEquals("returnStdout", sshConnectionMock.getReturnStdout());
71     }
72     @Test
73     public void testGetReturnStatus() {
74         sshConnectionMock.setReturnStatus(200);
75         assertEquals(200, sshConnectionMock.getReturnStatus());
76     }
77     @Test
78     public void testGetExecutedCommands() {
79         sshConnectionMock.getExecutedCommands().add("cls");
80         sshConnectionMock.getExecutedCommands().add("pwd");
81         assertNotNull(sshConnectionMock.getExecutedCommands());
82         assertEquals(false, sshConnectionMock.getExecutedCommands().isEmpty());
83     }
84     
85     @Test
86     public void testExecTimeout()
87     {
88         sshConnectionMock.setExecTimeout(20);
89         assertEquals(20,sshConnectionMock.getExecTimeout());
90     }
91 }