fb44763dff8dd9166a3b3667dd5c1e9269e9e1ff
[appc.git] / appc-adapters / appc-netconf-adapter / appc-netconf-adapter-bundle / src / test / java / org / onap / appc / adapter / netconf / jsch / TestNetconfClientJsch.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2018 Samsung
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  *
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.appc.adapter.netconf.jsch;
23
24 import com.jcraft.jsch.Session;
25 import org.junit.Assert;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.onap.appc.adapter.netconf.ConnectionDetails;
29 import org.onap.appc.adapter.netconf.NetconfConnectionDetails;
30 import org.onap.appc.adapter.netconf.internal.NetconfAdapter;
31 import org.onap.appc.exceptions.APPCException;
32
33 import java.io.IOException;
34 import java.util.Properties;
35
36 public class TestNetconfClientJsch {
37
38     NetconfClientJsch netconfClientJsch;
39
40     @Before
41     public void SetUp() {
42         netconfClientJsch = new NetconfClientJsch();
43     }
44
45     @Test (expected = APPCException.class)
46     public void testConnect() throws APPCException, IOException {
47         NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
48         connectionDetails.setHost("test");
49         connectionDetails.setPort(8080);
50         connectionDetails.setUsername("test");
51         connectionDetails.setPassword("test");
52         Properties additionalProperties = new Properties();
53         additionalProperties.setProperty("testKey1", "testParam1");
54         connectionDetails.setAdditionalProperties(additionalProperties);
55
56         netconfClientJsch.connect(connectionDetails);
57     }
58
59     @Test (expected = NullPointerException.class)
60     public void testExchangeMessage() throws APPCException, IOException {
61         String message = "test";
62
63         netconfClientJsch.exchangeMessage(message);
64     }
65
66     @Test (expected = NullPointerException.class)
67     public void testConfigure() throws APPCException, IOException {
68         String message = "test";
69
70         netconfClientJsch.configure(message);
71     }
72
73     @Test (expected = NullPointerException.class)
74     public void testConfigureOk() throws APPCException, IOException {
75         String message = "<ok/>";
76
77         netconfClientJsch.configure(message);
78     }
79
80     @Test (expected = NullPointerException.class)
81     public void testConfigureNull() throws APPCException, IOException {
82         String message = null;
83
84         netconfClientJsch.configure(message);
85     }
86
87     @Test (expected = NullPointerException.class)
88     public void testGetConfigure() throws APPCException, IOException {
89
90         netconfClientJsch.getConfiguration();
91     }
92
93     @Test
94     public void testDisconnect() throws APPCException, IOException {
95
96         netconfClientJsch.disconnect();
97     }
98 }