eefead21e8bf86b6e5b24e262dcde4c3f69ee643
[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.junit.Test
22 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfSessionImpl
23 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo
24 import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.NetconfDeviceSimulator
25
26
27 class NetconfSessionImplTest {
28
29     private var device: NetconfDeviceSimulator? = null
30     private var deviceInfo: DeviceInfo? = null
31
32     @Before
33     fun before() {
34         deviceInfo =DeviceInfo("name", "password", "localhost", 2224, "10")
35
36         device = NetconfDeviceSimulator(deviceInfo!!.port)
37         device!!.start()
38     }
39
40     @After
41     fun after() {
42         device!!.stop()
43     }
44
45     @Throws(Exception::class)
46     fun testNetconfSession() {
47         val netconfSession = NetconfSessionImpl(deviceInfo!!)
48
49         Assert.assertNotNull(netconfSession.getSessionId())
50         Assert.assertEquals("localhost:2224", netconfSession.getDeviceInfo().toString())
51
52         netconfSession.checkAndReestablish()
53
54         Assert.assertNotNull(netconfSession.getSessionId())
55         Assert.assertEquals("localhost:2224", netconfSession.getDeviceInfo().toString())
56
57         Assert.assertTrue(!netconfSession.getDeviceCapabilitiesSet().isEmpty())
58     }
59
60 }