diff options
Diffstat (limited to 'framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util')
7 files changed, 579 insertions, 0 deletions
diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/FlowClassifierManagerTestImpl.java b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/FlowClassifierManagerTestImpl.java new file mode 100644 index 00000000..fe5babbd --- /dev/null +++ b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/FlowClassifierManagerTestImpl.java @@ -0,0 +1,93 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.sfc.util; + +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentHashMap; + +import org.onosproject.vtnrsc.FlowClassifierId; +import org.onosproject.vtnrsc.FlowClassifier; +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierListener; +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; + +import com.google.common.collect.ImmutableList; + +/** + * Provides implementation of the Flow Classifier Service. + */ +public class FlowClassifierManagerTestImpl implements FlowClassifierService { + + private final ConcurrentMap<FlowClassifierId, FlowClassifier> flowClassifierStore = new ConcurrentHashMap<>(); + + @Override + public boolean exists(FlowClassifierId id) { + return flowClassifierStore.containsKey(id); + } + + @Override + public int getFlowClassifierCount() { + return flowClassifierStore.size(); + } + + @Override + public Iterable<FlowClassifier> getFlowClassifiers() { + return ImmutableList.copyOf(flowClassifierStore.values()); + } + + @Override + public FlowClassifier getFlowClassifier(FlowClassifierId id) { + return flowClassifierStore.get(id); + } + + @Override + public boolean createFlowClassifier(FlowClassifier flowClassifier) { + FlowClassifierId id = flowClassifier.flowClassifierId(); + + flowClassifierStore.put(id, flowClassifier); + if (!flowClassifierStore.containsKey(id)) { + return false; + } + return true; + } + + @Override + public boolean updateFlowClassifier(FlowClassifier flowClassifier) { + + if (!flowClassifierStore.containsKey(flowClassifier.flowClassifierId())) { + return false; + } + + flowClassifierStore.put(flowClassifier.flowClassifierId(), flowClassifier); + + if (!flowClassifier.equals(flowClassifierStore.get(flowClassifier.flowClassifierId()))) { + return false; + } + return true; + } + + @Override + public boolean removeFlowClassifier(FlowClassifierId id) { + return true; + } + + @Override + public void addListener(FlowClassifierListener listener) { + } + + @Override + public void removeListener(FlowClassifierListener listener) { + } +} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/FlowObjectiveServiceTestImpl.java b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/FlowObjectiveServiceTestImpl.java new file mode 100644 index 00000000..9da9ee94 --- /dev/null +++ b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/FlowObjectiveServiceTestImpl.java @@ -0,0 +1,53 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.sfc.util; + +import org.onosproject.net.DeviceId; +import org.onosproject.net.flowobjective.FlowObjectiveService; +import org.onosproject.net.flowobjective.FilteringObjective; +import org.onosproject.net.flowobjective.ForwardingObjective; +import org.onosproject.net.flowobjective.NextObjective; + +/** + * Testing version of implementation on FlowObjectiveService. + */ +public class FlowObjectiveServiceTestImpl implements FlowObjectiveService { + + @Override + public void filter(DeviceId deviceId, FilteringObjective filteringObjective) { + + } + + @Override + public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) { + + } + + @Override + public void next(DeviceId deviceId, NextObjective nextObjective) { + + } + + @Override + public int allocateNextId() { + return 0; + } + + @Override + public void initPolicy(String policy) { + + } +} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortChainManagerTestImpl.java b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortChainManagerTestImpl.java new file mode 100644 index 00000000..4a3ba03d --- /dev/null +++ b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortChainManagerTestImpl.java @@ -0,0 +1,85 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.sfc.util; + +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.Collections; + +import org.onosproject.vtnrsc.PortChain; +import org.onosproject.vtnrsc.PortChainId; +import org.onosproject.vtnrsc.portchain.PortChainService; +import org.onosproject.vtnrsc.portchain.PortChainEvent; +import org.onosproject.vtnrsc.portchain.PortChainListener; +import org.onosproject.event.AbstractListenerManager; + +/** + * Provides implementation of the portChainService. + */ +public class PortChainManagerTestImpl + extends AbstractListenerManager<PortChainEvent, PortChainListener> + implements PortChainService { + + private ConcurrentMap<PortChainId, PortChain> portChainStore = new ConcurrentHashMap<>(); + + @Override + public boolean exists(PortChainId portChainId) { + return portChainStore.containsKey(portChainId); + } + + @Override + public int getPortChainCount() { + return portChainStore.size(); + } + + @Override + public Iterable<PortChain> getPortChains() { + return Collections.unmodifiableCollection(portChainStore.values()); + } + + @Override + public PortChain getPortChain(PortChainId portChainId) { + return portChainStore.get(portChainId); + } + + @Override + public boolean createPortChain(PortChain portChain) { + portChainStore.put(portChain.portChainId(), portChain); + if (!portChainStore.containsKey(portChain.portChainId())) { + return false; + } + return true; + } + + @Override + public boolean updatePortChain(PortChain portChain) { + if (!portChainStore.containsKey(portChain.portChainId())) { + return false; + } + + portChainStore.put(portChain.portChainId(), portChain); + + if (!portChain.equals(portChainStore.get(portChain.portChainId()))) { + return false; + } + return true; + } + + @Override + public boolean removePortChain(PortChainId portChainId) { + return true; + } +} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairGroupManagerTestImpl.java b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairGroupManagerTestImpl.java new file mode 100644 index 00000000..ba31cd60 --- /dev/null +++ b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairGroupManagerTestImpl.java @@ -0,0 +1,89 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.sfc.util; + +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.Collections; + +import org.onosproject.vtnrsc.PortPairGroup; +import org.onosproject.vtnrsc.PortPairGroupId; +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupListener; +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; + +/** + * Provides implementation of the portPairGroupService. + */ +public class PortPairGroupManagerTestImpl implements PortPairGroupService { + + private ConcurrentMap<PortPairGroupId, PortPairGroup> portPairGroupStore = new ConcurrentHashMap<>(); + + @Override + public boolean exists(PortPairGroupId portPairGroupId) { + return portPairGroupStore.containsKey(portPairGroupId); + } + + @Override + public int getPortPairGroupCount() { + return portPairGroupStore.size(); + } + + @Override + public Iterable<PortPairGroup> getPortPairGroups() { + return Collections.unmodifiableCollection(portPairGroupStore.values()); + } + + @Override + public PortPairGroup getPortPairGroup(PortPairGroupId portPairGroupId) { + return portPairGroupStore.get(portPairGroupId); + } + + @Override + public boolean createPortPairGroup(PortPairGroup portPairGroup) { + portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup); + if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) { + return false; + } + return true; + } + + @Override + public boolean updatePortPairGroup(PortPairGroup portPairGroup) { + if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) { + return false; + } + + portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup); + + if (!portPairGroup.equals(portPairGroupStore.get(portPairGroup.portPairGroupId()))) { + return false; + } + return true; + } + + @Override + public boolean removePortPairGroup(PortPairGroupId portPairGroupId) { + return true; + } + + @Override + public void addListener(PortPairGroupListener listener) { + } + + @Override + public void removeListener(PortPairGroupListener listener) { + } +} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairManagerTestImpl.java b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairManagerTestImpl.java new file mode 100644 index 00000000..aff58823 --- /dev/null +++ b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairManagerTestImpl.java @@ -0,0 +1,89 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.sfc.util; + +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.Collections; + +import org.onosproject.vtnrsc.PortPair; +import org.onosproject.vtnrsc.PortPairId; +import org.onosproject.vtnrsc.portpair.PortPairListener; +import org.onosproject.vtnrsc.portpair.PortPairService; + +/** + * Provides implementation of the portPairService. + */ +public class PortPairManagerTestImpl implements PortPairService { + + private ConcurrentMap<PortPairId, PortPair> portPairStore = new ConcurrentHashMap<>(); + + @Override + public boolean exists(PortPairId portPairId) { + return portPairStore.containsKey(portPairId); + } + + @Override + public int getPortPairCount() { + return portPairStore.size(); + } + + @Override + public Iterable<PortPair> getPortPairs() { + return Collections.unmodifiableCollection(portPairStore.values()); + } + + @Override + public PortPair getPortPair(PortPairId portPairId) { + return portPairStore.get(portPairId); + } + + @Override + public boolean createPortPair(PortPair portPair) { + portPairStore.put(portPair.portPairId(), portPair); + if (!portPairStore.containsKey(portPair.portPairId())) { + return false; + } + return true; + } + + @Override + public boolean updatePortPair(PortPair portPair) { + if (!portPairStore.containsKey(portPair.portPairId())) { + return false; + } + + portPairStore.put(portPair.portPairId(), portPair); + + if (!portPair.equals(portPairStore.get(portPair.portPairId()))) { + return false; + } + return true; + } + + @Override + public boolean removePortPair(PortPairId portPairId) { + return true; + } + + @Override + public void addListener(PortPairListener listener) { + } + + @Override + public void removeListener(PortPairListener listener) { + } +} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VirtualPortManagerTestImpl.java b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VirtualPortManagerTestImpl.java new file mode 100644 index 00000000..de056a78 --- /dev/null +++ b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VirtualPortManagerTestImpl.java @@ -0,0 +1,98 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.sfc.util; + +import java.util.Collection; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentHashMap; + +import org.onlab.packet.IpAddress; +import org.onosproject.net.DeviceId; +import org.onosproject.vtnrsc.FixedIp; +import org.onosproject.vtnrsc.TenantId; +import org.onosproject.vtnrsc.VirtualPort; +import org.onosproject.vtnrsc.VirtualPortId; +import org.onosproject.vtnrsc.TenantNetworkId; +import org.onosproject.vtnrsc.virtualport.VirtualPortService; + +/** + * Provides implementation of the VirtualPort APIs. + */ +public class VirtualPortManagerTestImpl implements VirtualPortService { + + protected ConcurrentMap<VirtualPortId, VirtualPort> vPortStore = new ConcurrentHashMap<>(); + + @Override + public boolean exists(VirtualPortId vPortId) { + return vPortStore.containsKey(vPortId); + } + + @Override + public VirtualPort getPort(VirtualPortId vPortId) { + return vPortStore.get(vPortId); + } + + @Override + public VirtualPort getPort(FixedIp fixedIP) { + return null; + } + + @Override + public Collection<VirtualPort> getPorts() { + return null; + } + + @Override + public Collection<VirtualPort> getPorts(TenantNetworkId networkId) { + return null; + } + + @Override + public Collection<VirtualPort> getPorts(TenantId tenantId) { + return null; + } + + @Override + public Collection<VirtualPort> getPorts(DeviceId deviceId) { + return null; + } + + @Override + public VirtualPort getPort(TenantNetworkId networkId, IpAddress ipAddress) { + return null; + } + + @Override + public boolean createPorts(Iterable<VirtualPort> vPorts) { + for (VirtualPort vPort : vPorts) { + vPortStore.put(vPort.portId(), vPort); + if (!vPortStore.containsKey(vPort.portId())) { + return false; + } + } + return true; + } + + @Override + public boolean updatePorts(Iterable<VirtualPort> vPorts) { + return true; + } + + @Override + public boolean removePorts(Iterable<VirtualPortId> vPortIds) { + return true; + } +} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VtnRscManagerTestImpl.java b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VtnRscManagerTestImpl.java new file mode 100644 index 00000000..4188cee6 --- /dev/null +++ b/framework/src/onos/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VtnRscManagerTestImpl.java @@ -0,0 +1,72 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.sfc.util; + +import java.util.Iterator; + +import org.onlab.packet.MacAddress; +import org.onosproject.net.Device; +import org.onosproject.net.DeviceId; +import org.onosproject.net.HostId; +import org.onosproject.vtnrsc.SegmentationId; +import org.onosproject.vtnrsc.TenantId; +import org.onosproject.vtnrsc.VirtualPortId; +import org.onosproject.vtnrsc.event.VtnRscListener; +import org.onosproject.vtnrsc.service.VtnRscService; + +/** + * Provides implementation of the VtnRsc service. + */ +public class VtnRscManagerTestImpl implements VtnRscService { + @Override + public void addListener(VtnRscListener listener) { + } + + @Override + public void removeListener(VtnRscListener listener) { + } + + @Override + public SegmentationId getL3vni(TenantId tenantId) { + return null; + } + + @Override + public Iterator<Device> getClassifierOfTenant(TenantId tenantId) { + return null; + } + + @Override + public Iterator<Device> getSFFOfTenant(TenantId tenantId) { + return null; + } + + @Override + public MacAddress getGatewayMac(HostId hostId) { + return null; + } + + @Override + public boolean isServiceFunction(VirtualPortId portId) { + // TODO Auto-generated method stub + return false; + } + + @Override + public DeviceId getSFToSFFMaping(VirtualPortId portId) { + return DeviceId.deviceId("www.google.com"); + } +} |