2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * ============LICENSE_END=========================================================
22 package org.onap.appc.adapter.netconf.jsch;
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;
33 import java.io.IOException;
34 import java.util.Properties;
36 public class TestNetconfClientJsch {
38 NetconfClientJsch netconfClientJsch;
42 netconfClientJsch = new NetconfClientJsch();
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);
56 netconfClientJsch.connect(connectionDetails);
59 @Test (expected = NullPointerException.class)
60 public void testExchangeMessage() throws APPCException, IOException {
61 String message = "test";
63 netconfClientJsch.exchangeMessage(message);
66 @Test (expected = NullPointerException.class)
67 public void testConfigure() throws APPCException, IOException {
68 String message = "test";
70 netconfClientJsch.configure(message);
73 @Test (expected = NullPointerException.class)
74 public void testConfigureOk() throws APPCException, IOException {
75 String message = "<ok/>";
77 netconfClientJsch.configure(message);
80 @Test (expected = NullPointerException.class)
81 public void testConfigureNull() throws APPCException, IOException {
82 String message = null;
84 netconfClientJsch.configure(message);
87 @Test (expected = NullPointerException.class)
88 public void testGetConfigure() throws APPCException, IOException {
90 netconfClientJsch.getConfiguration();
94 public void testDisconnect() throws APPCException, IOException {
96 netconfClientJsch.disconnect();