Coverage for org.onap.appc.adapter.ssh classes
[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 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *     http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
19 */
20 package org.onap.appc.adapter.ssh;
21
22 import static org.junit.Assert.*;
23
24 import org.junit.Before;
25 import org.junit.Test;
26
27 public class TestSshConnectionMock {
28
29     private SshConnectionMock sshConnectionMock;
30     @Before
31     public void setUp() {
32         sshConnectionMock=new SshConnectionMock("localhost", 8080, "myUser", "myPassword");
33     }
34     
35     @Test
36     public void testGetHost() {
37         assertNotNull(sshConnectionMock.getHost());
38         assertEquals(sshConnectionMock.getHost(), "localhost");
39     }
40
41     @Test
42     public void testGetPort() {
43         assertNotNull(sshConnectionMock.getPort());
44         assertEquals(sshConnectionMock.getPort(), 8080);
45     }
46
47     @Test
48     public void testGetUsername() {
49         assertNotNull(sshConnectionMock.getUsername());
50         assertEquals(sshConnectionMock.getUsername(), "myUser");
51     }
52
53     @Test
54     public void testGetPassword() {
55         assertNotNull(sshConnectionMock.getPassword());
56         assertEquals(sshConnectionMock.getPassword(), "myPassword");
57     }
58     @Test
59     public void testGetReturnStderr() {
60         sshConnectionMock.setReturnStderr("returnStderr");
61         assertNotNull(sshConnectionMock.getReturnStderr());
62         assertEquals(sshConnectionMock.getReturnStderr(), "returnStderr");
63     }
64     @Test
65     public void testGetReturnStdout() {
66         sshConnectionMock.setReturnStdout("returnStdout");
67         assertNotNull(sshConnectionMock.getReturnStdout());
68         assertEquals(sshConnectionMock.getReturnStdout(), "returnStdout");
69     }
70     @Test
71     public void testGetReturnStatus() {
72         sshConnectionMock.setReturnStatus(200);
73         assertNotNull(sshConnectionMock.getReturnStatus());
74         assertEquals(sshConnectionMock.getReturnStatus(), 200);
75     }
76     @Test
77     public void testGetExecutedCommands() {
78         sshConnectionMock.getExecutedCommands().add("cls");
79         sshConnectionMock.getExecutedCommands().add("pwd");
80         assertNotNull(sshConnectionMock.getExecutedCommands());
81         assertEquals(false, sshConnectionMock.getExecutedCommands().isEmpty());
82     }
83 }