blob: c2c3e0a404476e97317f67f720fc5f886d2fad8a [file] [log] [blame]
xueliang37a396a2016-09-09 14:43:49 +09001/*
2 * Copyright 2016-present Open Networking Laboratory
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
17package org.onosproject.drivers.fujitsu;
18
19import org.onosproject.netconf.NetconfDevice;
20import org.onosproject.netconf.NetconfDeviceInfo;
21import org.onosproject.netconf.NetconfException;
22import org.onosproject.netconf.NetconfSession;
23
24
25/**
26* Mock DefaultNetconfDevice.
27*/
28class FujitsuNetconfDeviceMock implements NetconfDevice {
29
30 private NetconfDeviceInfo netconfDeviceInfo;
31 private boolean deviceState = false;
32 private NetconfSession netconfSession;
33
34 /**
35 * Creates a new NETCONF device with the information provided.
36 *
37 * @param deviceInfo information about the device to be created.
38 * @throws NetconfException if there are problems in creating or establishing
39 * the underlying NETCONF connection and session.
40 */
41 public FujitsuNetconfDeviceMock(NetconfDeviceInfo deviceInfo) throws NetconfException {
42 netconfDeviceInfo = deviceInfo;
43 try {
44 netconfSession = new FujitsuNetconfSessionMock();
45 deviceState = true;
46 } catch (Exception e) {
47 throw new NetconfException("Cannot create Connection and Session");
48 }
49 }
50
51 @Override
52 public boolean isActive() {
53 return deviceState;
54 }
55
56 @Override
57 public NetconfSession getSession() {
58 return netconfSession;
59 }
60
61 @Override
62 public void disconnect() {
63 deviceState = false;
64 netconfSession = null;
65 }
66
67 @Override
68 public NetconfDeviceInfo getDeviceInfo() {
69 return netconfDeviceInfo;
70 }
71
72}