Committed by
Thomas Vachuska
[ONOS-3163] Test stub on FlowClassifierManager and PortChainManager
Change-Id: I1edaf6e50f77e2d5004e102bd13786854af523b1
Showing
2 changed files
with
178 additions
and
0 deletions
apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/FlowClassifierManagerTestImpl.java
0 → 100644
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.sfc.util; | ||
17 | + | ||
18 | +import java.util.concurrent.ConcurrentMap; | ||
19 | +import java.util.concurrent.ConcurrentHashMap; | ||
20 | + | ||
21 | +import org.onosproject.vtnrsc.FlowClassifierId; | ||
22 | +import org.onosproject.vtnrsc.FlowClassifier; | ||
23 | +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierListener; | ||
24 | +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; | ||
25 | + | ||
26 | +import com.google.common.collect.ImmutableList; | ||
27 | + | ||
28 | +/** | ||
29 | + * Provides implementation of the Flow Classifier Service. | ||
30 | + */ | ||
31 | +public class FlowClassifierManagerTestImpl implements FlowClassifierService { | ||
32 | + | ||
33 | + private final ConcurrentMap<FlowClassifierId, FlowClassifier> flowClassifierStore = new ConcurrentHashMap<>(); | ||
34 | + | ||
35 | + @Override | ||
36 | + public boolean exists(FlowClassifierId id) { | ||
37 | + return flowClassifierStore.containsKey(id); | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public int getFlowClassifierCount() { | ||
42 | + return flowClassifierStore.size(); | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + public Iterable<FlowClassifier> getFlowClassifiers() { | ||
47 | + return ImmutableList.copyOf(flowClassifierStore.values()); | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public FlowClassifier getFlowClassifier(FlowClassifierId id) { | ||
52 | + return flowClassifierStore.get(id); | ||
53 | + } | ||
54 | + | ||
55 | + @Override | ||
56 | + public boolean createFlowClassifier(FlowClassifier flowClassifier) { | ||
57 | + FlowClassifierId id = flowClassifier.flowClassifierId(); | ||
58 | + | ||
59 | + flowClassifierStore.put(id, flowClassifier); | ||
60 | + if (!flowClassifierStore.containsKey(id)) { | ||
61 | + return false; | ||
62 | + } | ||
63 | + return true; | ||
64 | + } | ||
65 | + | ||
66 | + @Override | ||
67 | + public boolean updateFlowClassifier(FlowClassifier flowClassifier) { | ||
68 | + | ||
69 | + if (!flowClassifierStore.containsKey(flowClassifier.flowClassifierId())) { | ||
70 | + return false; | ||
71 | + } | ||
72 | + | ||
73 | + flowClassifierStore.put(flowClassifier.flowClassifierId(), flowClassifier); | ||
74 | + | ||
75 | + if (!flowClassifier.equals(flowClassifierStore.get(flowClassifier.flowClassifierId()))) { | ||
76 | + return false; | ||
77 | + } | ||
78 | + return true; | ||
79 | + } | ||
80 | + | ||
81 | + @Override | ||
82 | + public boolean removeFlowClassifier(FlowClassifierId id) { | ||
83 | + return true; | ||
84 | + } | ||
85 | + | ||
86 | + @Override | ||
87 | + public void addListener(FlowClassifierListener listener) { | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public void removeListener(FlowClassifierListener listener) { | ||
92 | + } | ||
93 | +} |
1 | +/* | ||
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 | + */ | ||
16 | +package org.onosproject.sfc.util; | ||
17 | + | ||
18 | +import java.util.concurrent.ConcurrentMap; | ||
19 | +import java.util.concurrent.ConcurrentHashMap; | ||
20 | +import java.util.Collections; | ||
21 | + | ||
22 | +import org.onosproject.vtnrsc.PortChain; | ||
23 | +import org.onosproject.vtnrsc.PortChainId; | ||
24 | +import org.onosproject.vtnrsc.portchain.PortChainService; | ||
25 | +import org.onosproject.vtnrsc.portchain.PortChainEvent; | ||
26 | +import org.onosproject.vtnrsc.portchain.PortChainListener; | ||
27 | +import org.onosproject.event.AbstractListenerManager; | ||
28 | + | ||
29 | +/** | ||
30 | + * Provides implementation of the portChainService. | ||
31 | + */ | ||
32 | +public class PortChainManagerTestImpl | ||
33 | + extends AbstractListenerManager<PortChainEvent, PortChainListener> | ||
34 | + implements PortChainService { | ||
35 | + | ||
36 | + private ConcurrentMap<PortChainId, PortChain> portChainStore = new ConcurrentHashMap<>(); | ||
37 | + | ||
38 | + @Override | ||
39 | + public boolean exists(PortChainId portChainId) { | ||
40 | + return portChainStore.containsKey(portChainId); | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + public int getPortChainCount() { | ||
45 | + return portChainStore.size(); | ||
46 | + } | ||
47 | + | ||
48 | + @Override | ||
49 | + public Iterable<PortChain> getPortChains() { | ||
50 | + return Collections.unmodifiableCollection(portChainStore.values()); | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public PortChain getPortChain(PortChainId portChainId) { | ||
55 | + return portChainStore.get(portChainId); | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public boolean createPortChain(PortChain portChain) { | ||
60 | + portChainStore.put(portChain.portChainId(), portChain); | ||
61 | + if (!portChainStore.containsKey(portChain.portChainId())) { | ||
62 | + return false; | ||
63 | + } | ||
64 | + return true; | ||
65 | + } | ||
66 | + | ||
67 | + @Override | ||
68 | + public boolean updatePortChain(PortChain portChain) { | ||
69 | + if (!portChainStore.containsKey(portChain.portChainId())) { | ||
70 | + return false; | ||
71 | + } | ||
72 | + | ||
73 | + portChainStore.put(portChain.portChainId(), portChain); | ||
74 | + | ||
75 | + if (!portChain.equals(portChainStore.get(portChain.portChainId()))) { | ||
76 | + return false; | ||
77 | + } | ||
78 | + return true; | ||
79 | + } | ||
80 | + | ||
81 | + @Override | ||
82 | + public boolean removePortChain(PortChainId portChainId) { | ||
83 | + return true; | ||
84 | + } | ||
85 | +} |
-
Please register or login to post a comment