750a3bafa77f54e386832e6afc6d69ac87c59e89
[appc.git] /
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", "sampleKeyFile");
33     }
34     
35     @Test
36     public void testGetHost() {
37         assertEquals("localhost", sshConnectionMock.getHost());
38     }
39
40     @Test
41     public void testGetPort() {
42         assertEquals(8080, sshConnectionMock.getPort());
43     }
44
45     @Test
46     public void testGetUsername() {
47         assertEquals("myUser", sshConnectionMock.getUsername());
48     }
49
50     @Test
51     public void testGetPassword() {
52         assertEquals("myPassword", sshConnectionMock.getPassword());
53     }
54
55     @Test
56     public void testKeyFile() {
57         assertEquals("sampleKeyFile", sshConnectionMock.getKeyFile());
58     }
59
60     @Test
61     public void testGetReturnStderr() {
62         sshConnectionMock.setReturnStderr("returnStderr");
63         assertEquals("returnStderr", sshConnectionMock.getReturnStderr());
64     }
65     @Test
66     public void testGetReturnStdout() {
67         sshConnectionMock.setReturnStdout("returnStdout");
68         assertEquals("returnStdout", sshConnectionMock.getReturnStdout());
69     }
70     @Test
71     public void testGetReturnStatus() {
72         sshConnectionMock.setReturnStatus(200);
73         assertEquals(200, sshConnectionMock.getReturnStatus());
74     }
75     @Test
76     public void testGetExecutedCommands() {
77         sshConnectionMock.getExecutedCommands().add("cls");
78         sshConnectionMock.getExecutedCommands().add("pwd");
79         assertNotNull(sshConnectionMock.getExecutedCommands());
80         assertEquals(false, sshConnectionMock.getExecutedCommands().isEmpty());
81     }
82 }