53048986aab9305f498e348daadd8d510e53c922
[ccsdk/sli.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.ccsdk.sli.adaptors.ssh;
21
22 import org.junit.Before;
23 import org.junit.Test;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertFalse;
27 import static org.junit.Assert.assertNotNull;
28
29 public class TestSshAdaptorMock {
30     private SshAdaptorMock sshAdaptorMock;
31
32     @Before
33     public void setUp() {
34         sshAdaptorMock = new SshAdaptorMock();
35     }
36
37     @Test
38     public void testGetReturnStatus() {
39         sshAdaptorMock.setReturnStatus(200);
40         assertEquals(sshAdaptorMock.getReturnStatus(), 200);
41     }
42
43     @Test
44     public void testGetReturnStdout() {
45         sshAdaptorMock.setReturnStdout("success");
46         assertNotNull(sshAdaptorMock.getReturnStdout());
47         assertEquals(sshAdaptorMock.getReturnStdout(), "success");
48     }
49
50     @Test
51     public void testGetReturnStderr() {
52         sshAdaptorMock.setReturnStderr("error");
53         assertNotNull(sshAdaptorMock.getReturnStderr());
54         assertEquals(sshAdaptorMock.getReturnStderr(), "error");
55     }
56
57     @Test
58     public void testGetConnectionMocks() {
59         sshAdaptorMock.setReturnStatus(200);
60         sshAdaptorMock.setReturnStdout("success");
61         sshAdaptorMock.setReturnStderr("error");
62         sshAdaptorMock.getConnection("localhost", 8080, "myUser", "myPassword");
63         assertFalse(sshAdaptorMock.getConnectionMocks().isEmpty());
64         assertNotNull(sshAdaptorMock.getConnectionMocks());
65     }
66
67     @Test
68     public void testGetConnection() {
69         SshAdaptorMock sshAdaptorMock = new SshAdaptorMock();
70         sshAdaptorMock.setReturnStatus(200);
71         sshAdaptorMock.setReturnStdout("success");
72         sshAdaptorMock.setReturnStderr("error");
73         sshAdaptorMock.getConnection("localhost", 8080, "keyFile");
74         assertFalse(sshAdaptorMock.getConnectionMocks().isEmpty());
75     }
76
77 }