blob: bfa6d51709f1dd12eaa99c52e3b4ad070610b0d8 [file] [log] [blame]
Sean Condonfae8e662016-12-15 10:25:13 +00001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Sean Condonfae8e662016-12-15 10:25:13 +00003 *
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 */
16package org.onosproject.drivers.netconf;
17
18import java.util.HashMap;
19import java.util.Map;
20
21import org.onosproject.core.CoreService;
22import org.onosproject.mastership.MastershipService;
23import org.onosproject.net.DeviceId;
24import org.onosproject.net.driver.Behaviour;
25import org.onosproject.net.driver.DefaultDriver;
26import org.onosproject.net.driver.DefaultDriverData;
27import org.onosproject.net.driver.Driver;
28import org.onosproject.net.driver.DriverData;
29import org.onosproject.net.driver.DriverHandler;
30import org.onosproject.net.flow.FlowRuleProgrammable;
31import org.onosproject.netconf.NetconfController;
32import org.onosproject.netconf.NetconfException;
33
34public class MockDriverHandler implements DriverHandler {
35
36 private DriverData mockDriverData;
37
38 private NetconfController ncc;
39 private CoreService coreService;
40 private MastershipService mastershipService;
41
42 public MockDriverHandler() throws NetconfException {
43 Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours =
44 new HashMap<Class<? extends Behaviour>, Class<? extends Behaviour>>();
45 behaviours.put(FlowRuleProgrammable.class, FlowRuleProgrammable.class);
46
47 Map<String, String> properties = new HashMap<String, String>();
48
49 Driver mockDriver =
50 new DefaultDriver("mockDriver", null, "ONOSProject", "1.0.0", "1.0.0", behaviours, properties);
51 DeviceId mockDeviceId = DeviceId.deviceId("netconf:1.2.3.4:830");
52 mockDriverData = new DefaultDriverData(mockDriver, mockDeviceId);
53
54
55 ncc = new MockNetconfController();
56 ncc.connectDevice(mockDeviceId);
57
58 coreService = new MockCoreService();
59 mastershipService = new MockMastershipService();
60 }
61
62 @Override
63 public Driver driver() {
64 return mockDriverData.driver();
65 }
66
67 @Override
68 public DriverData data() {
69 return mockDriverData;
70 }
71
72 @Override
73 public <T extends Behaviour> T behaviour(Class<T> behaviourClass) {
74 // TODO Auto-generated method stub
75 return null;
76 }
77
78 @Override
79 public <T> T get(Class<T> serviceClass) {
80 if (serviceClass.equals(NetconfController.class)) {
81 return (T) ncc;
82
83 } else if (serviceClass.equals(CoreService.class)) {
84 return (T) coreService;
85
86 } else if (serviceClass.equals(MastershipService.class)) {
87 return (T) mastershipService;
88
89 }
90
91 return null;
92 }
93
94}