blob: b018f42ab93103f0a720bfdb538d9ae8c77a8c9c [file] [log] [blame]
Ray Milkey7ec0d1b2015-11-13 08:51:35 -08001/*
2 * Copyright 2015 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 */
16package org.onosproject.openflow;
17
18import java.util.ArrayList;
19import java.util.HashMap;
20import java.util.List;
21import java.util.Map;
22
23import org.onosproject.openflow.controller.Dpid;
24import org.onosproject.openflow.controller.OpenFlowSwitchListener;
25import org.onosproject.openflow.controller.RoleState;
26import org.projectfloodlight.openflow.protocol.OFPortStatus;
27
28/**
29 * Test harness for a switch listener.
30 */
31public class OpenFlowSwitchListenerAdapter implements OpenFlowSwitchListener {
32 final List<Dpid> removedDpids = new ArrayList<>();
33 final List<Dpid> addedDpids = new ArrayList<>();
34 final List<Dpid> changedDpids = new ArrayList<>();
35 final Map<Dpid, OFPortStatus> portChangedDpids = new HashMap<>();
36
37 @Override
38 public void switchAdded(Dpid dpid) {
39 addedDpids.add(dpid);
40 }
41
42 @Override
43 public void switchRemoved(Dpid dpid) {
44 removedDpids.add(dpid);
45 }
46
47 @Override
48 public void switchChanged(Dpid dpid) {
49 changedDpids.add(dpid);
50 }
51
52 @Override
53 public void portChanged(Dpid dpid, OFPortStatus status) {
54 portChangedDpids.put(dpid, status);
55 }
56
57 @Override
58 public void receivedRoleReply(Dpid dpid, RoleState requested, RoleState response) {
59 // Stub
60 }
61
62 public List<Dpid> removedDpids() {
63 return removedDpids;
64 }
65
66 public List<Dpid> addedDpids() {
67 return addedDpids;
68 }
69
70 public List<Dpid> changedDpids() {
71 return changedDpids;
72 }
73
74 public Map<Dpid, OFPortStatus> portChangedDpids() {
75 return portChangedDpids;
76 }
77}