Simon Hunt | 2ff1759 | 2017-11-08 15:34:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 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 | |
| 17 | package org.onosproject.segmentrouting; |
| 18 | |
| 19 | import org.onosproject.net.ConnectPoint; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.PortNumber; |
| 22 | |
| 23 | import java.util.ArrayList; |
| 24 | import java.util.List; |
| 25 | |
| 26 | /** |
| 27 | * An augmented implementation of {@link PortAuthTracker}, so that we can |
| 28 | * instrument its behavior for unit test assertions. |
| 29 | */ |
| 30 | class AugmentedPortAuthTracker extends PortAuthTracker { |
| 31 | |
| 32 | // instrument blocking flow activity, so we can see when we get hits |
| 33 | final List<ConnectPoint> installed = new ArrayList<>(); |
| 34 | final List<ConnectPoint> cleared = new ArrayList<>(); |
| 35 | |
| 36 | |
| 37 | void resetMetrics() { |
| 38 | installed.clear(); |
| 39 | cleared.clear(); |
| 40 | } |
| 41 | |
| 42 | @Override |
| 43 | void installBlockingFlow(DeviceId d, PortNumber p) { |
| 44 | super.installBlockingFlow(d, p); |
| 45 | installed.add(new ConnectPoint(d, p)); |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | void clearBlockingFlow(DeviceId d, PortNumber p) { |
| 50 | super.clearBlockingFlow(d, p); |
| 51 | cleared.add(new ConnectPoint(d, p)); |
| 52 | } |
| 53 | } |