4ee48bc824585a93d866bd39666dcbf6f9b8db7b
[ccsdk/cds.git] /
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
17
18 import org.junit.After
19 import org.junit.Assert
20 import org.junit.Before
21 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfSessionImpl
22 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
23 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.NetconfDeviceSimulator
24
25
26 class NetconfSessionImplTest {
27
28     private var device: NetconfDeviceSimulator? = null
29     private var deviceInfo: DeviceInfo? = null
30
31     @Before
32     fun before() {
33         deviceInfo = DeviceInfo().apply {
34             name = "name"
35             pass = "password"
36             ipAddress = "localhost"
37             port = 2224
38             connectTimeoutSec = 10
39         }
40
41         device = NetconfDeviceSimulator(deviceInfo!!.port)
42         device!!.start()
43     }
44
45     @After
46     fun after() {
47         device!!.stop()
48     }
49
50     @Throws(Exception::class)
51     fun testNetconfSession() {
52         val netconfSession = NetconfSessionImpl(deviceInfo!!)
53
54         Assert.assertNotNull(netconfSession.getSessionId())
55         Assert.assertEquals("localhost:2224", netconfSession.getDeviceInfo().toString())
56
57         netconfSession.checkAndReestablish()
58
59         Assert.assertNotNull(netconfSession.getSessionId())
60         Assert.assertEquals("localhost:2224", netconfSession.getDeviceInfo().toString())
61
62         Assert.assertTrue(!netconfSession.getDeviceCapabilitiesSet().isEmpty())
63     }
64
65 }