Sean Condon | 0e89bda | 2017-03-21 14:23:19 +0000 | [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 | package org.onosproject.incubator.net.l2monitoring.cfm.impl; |
| 17 | |
| 18 | import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMep; |
| 19 | import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepEntry; |
| 20 | import org.onosproject.incubator.net.l2monitoring.cfm.Mep; |
| 21 | import org.onosproject.incubator.net.l2monitoring.cfm.MepEntry; |
| 22 | import org.onosproject.incubator.net.l2monitoring.cfm.MepLbCreate; |
| 23 | import org.onosproject.incubator.net.l2monitoring.cfm.MepLtCreate; |
| 24 | import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort; |
| 25 | import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId; |
| 26 | import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId; |
| 27 | import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException; |
| 28 | import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepProgrammable; |
| 29 | import org.onosproject.net.PortNumber; |
| 30 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 31 | |
| 32 | import java.util.ArrayList; |
| 33 | import java.util.Collection; |
| 34 | import java.util.List; |
| 35 | |
| 36 | import static org.onosproject.incubator.net.l2monitoring.cfm.impl.CfmMepManagerTest.*; |
| 37 | |
| 38 | /** |
| 39 | * A dummy implementation of the CfmMepProgrammable for test purposes. |
| 40 | */ |
| 41 | public class TestCfmMepProgrammable extends AbstractHandlerBehaviour implements CfmMepProgrammable { |
| 42 | |
| 43 | private List<Mep> deviceMepList; |
| 44 | |
| 45 | public TestCfmMepProgrammable() throws CfmConfigException { |
| 46 | deviceMepList = new ArrayList<>(); |
| 47 | |
| 48 | deviceMepList.add(DefaultMep.builder(MEPID1, DEVICE_ID1, PortNumber.P0, |
| 49 | Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build()); |
| 50 | deviceMepList.add(DefaultMep.builder(MEPID2, DEVICE_ID2, PortNumber.portNumber(2), |
| 51 | Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build()); |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public Collection<MepEntry> getAllMeps(MdId mdName, MaIdShort maName) throws CfmConfigException { |
| 56 | return null; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public MepEntry getMep(MdId mdName, MaIdShort maName, MepId mepId) throws CfmConfigException { |
| 61 | for (Mep mep:deviceMepList) { |
| 62 | if (mep.mdId().equals(mdName) && mep.maId().equals(maName) && mep.mepId().equals(mepId)) { |
| 63 | return DefaultMepEntry.builder(mep).buildEntry(); |
| 64 | } |
| 65 | } |
| 66 | return null; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public boolean deleteMep(MdId mdName, MaIdShort maName, MepId mepId) throws CfmConfigException { |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public boolean createMep(MdId mdName, MaIdShort maName, Mep mep) throws CfmConfigException { |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public void transmitLoopback(MdId mdName, MaIdShort maName, MepId mepId, MepLbCreate lbCreate) |
| 81 | throws CfmConfigException { |
| 82 | |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public void abortLoopback(MdId mdName, MaIdShort maName, MepId mepId) throws CfmConfigException { |
| 87 | |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public void transmitLinktrace(MdId mdName, MaIdShort maName, MepId mepId, MepLtCreate ltCreate) |
| 92 | throws CfmConfigException { |
| 93 | |
| 94 | } |
| 95 | } |