2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.openflow.md.core.sal;
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.Collections;
14 import java.util.List;
16 import java.util.concurrent.ExecutionException;
17 import java.util.concurrent.Executors;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22 import org.mockito.Matchers;
23 import org.mockito.Mock;
24 import org.mockito.Mockito;
25 import org.mockito.runners.MockitoJUnitRunner;
26 import org.opendaylight.controller.sal.common.util.Rpcs;
27 import org.opendaylight.openflowplugin.openflow.md.OFConstants;
28 import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
29 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
30 import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatchService;
31 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
32 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
33 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
34 import org.opendaylight.openflowplugin.statistics.MessageSpy;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.CommonPort.PortNumber;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortKey;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutputBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutputBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInputBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutputBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInputBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutputBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutputBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutputBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInputBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutputBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInputBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInputBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutputBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPortBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutputBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInputBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInputBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTable;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
137 import org.opendaylight.yangtools.yang.binding.DataContainer;
138 import org.opendaylight.yangtools.yang.common.RpcError;
139 import org.opendaylight.yangtools.yang.common.RpcResult;
141 import com.google.common.util.concurrent.Futures;
142 import com.google.common.util.concurrent.MoreExecutors;
145 * simple NPE smoke test
147 @RunWith(MockitoJUnitRunner.class)
148 public class ModelDrivenSwitchImplTest {
150 private ModelDrivenSwitchImpl mdSwitchOF10;
151 private ModelDrivenSwitchImpl mdSwitchOF13;
154 private SessionContext context;
156 private ConnectionConductor conductor;
158 private IMessageDispatchService messageDispatchService;
160 private GetFeaturesOutput features;
162 private MessageSpy<DataContainer> messageSpy;
165 * @throws java.lang.Exception
168 public void setUp() throws Exception {
169 Mockito.when(context.getPrimaryConductor()).thenReturn(conductor);
170 Mockito.when(context.getMessageDispatchService()).thenReturn(messageDispatchService);
171 Mockito.when(conductor.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0)
172 .thenReturn(OFConstants.OFP_VERSION_1_3);
173 Mockito.when(context.getFeatures()).thenReturn(features);
174 Mockito.when(features.getDatapathId()).thenReturn(BigInteger.valueOf(1));
176 OFSessionUtil.getSessionManager().setRpcPool(MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)));
177 OFSessionUtil.getSessionManager().setMessageSpy(messageSpy);
178 OpenflowPortsUtil.init();
180 mdSwitchOF10 = new ModelDrivenSwitchImpl(null, null, context);
181 mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context);
186 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#addFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)}
188 * @throws ExecutionException
189 * @throws InterruptedException
192 public void testAddFlow() throws InterruptedException, ExecutionException {
193 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
194 updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
195 Set<RpcError> errorSet = Collections.emptySet();
196 RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
198 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
199 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
201 AddFlowInputBuilder input = new AddFlowInputBuilder();
202 input.setMatch(createMatch());
204 Mockito.when(features.getVersion()).thenReturn((short)1);
205 mdSwitchOF10.addFlow(input.build()).get();
206 Mockito.when(features.getVersion()).thenReturn((short)4);
207 mdSwitchOF13.addFlow(input.build()).get();
208 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
209 Matchers.any(FlowModInput.class),
210 Matchers.any(SwitchConnectionDistinguisher.class));
215 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#removeFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)}
217 * @throws ExecutionException
218 * @throws InterruptedException
221 public void testRemoveFlow() throws InterruptedException, ExecutionException {
222 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
223 updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
224 Set<RpcError> errorSet = Collections.emptySet();
225 RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
227 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
228 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
230 RemoveFlowInputBuilder input = new RemoveFlowInputBuilder();
231 input.setMatch(createMatch());
233 Mockito.when(features.getVersion()).thenReturn((short)1);
234 mdSwitchOF10.removeFlow(input.build()).get();
235 Mockito.when(features.getVersion()).thenReturn((short)4);
236 mdSwitchOF13.removeFlow(input.build()).get();
237 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
238 Matchers.any(FlowModInput.class),
239 Matchers.any(SwitchConnectionDistinguisher.class));
245 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#updateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)}
247 * @throws ExecutionException
248 * @throws InterruptedException
251 public void testUpdateFlow() throws InterruptedException, ExecutionException {
252 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
253 updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
254 Set<RpcError> errorSet = Collections.emptySet();
255 RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
257 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
258 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
260 UpdateFlowInputBuilder input = new UpdateFlowInputBuilder();
261 UpdatedFlowBuilder updatedFlow = new UpdatedFlowBuilder();
262 updatedFlow.setBarrier(false);
263 updatedFlow.setMatch(createMatch());
264 updatedFlow.setPriority(65);
265 updatedFlow.setFlags(new FlowModFlags(true, false, true, false, true));
266 input.setUpdatedFlow(updatedFlow.build());
267 OriginalFlowBuilder originalFlowBuilder = new OriginalFlowBuilder();
268 originalFlowBuilder.setMatch(createMatch());
269 originalFlowBuilder.setPriority(65);
270 originalFlowBuilder.setFlags(new FlowModFlags(true, false, true, false, true));
271 input.setOriginalFlow(originalFlowBuilder.build());
273 Mockito.when(features.getVersion()).thenReturn((short)1);
274 mdSwitchOF10.updateFlow(input.build()).get();
275 Mockito.when(features.getVersion()).thenReturn((short)4);
276 mdSwitchOF13.updateFlow(input.build()).get();
277 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
278 Matchers.any(FlowModInput.class),
279 Matchers.any(SwitchConnectionDistinguisher.class));
284 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
285 * addGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
288 * @throws ExecutionException
289 * @throws InterruptedException
292 public void testAddGroup() throws InterruptedException, ExecutionException {
293 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
294 updateGroupOutput.setTransactionId(new TransactionId(new BigInteger("42")));
295 Set<RpcError> errorSet = Collections.emptySet();
296 RpcResult<UpdateGroupOutput> result = Rpcs.getRpcResult(true, updateGroupOutput.build(), errorSet);
298 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
299 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
301 AddGroupInputBuilder input = new AddGroupInputBuilder();
302 input.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
303 input.setGroupId(new GroupId(789L));
305 mdSwitchOF10.addGroup(input.build()).get();
306 mdSwitchOF13.addGroup(input.build()).get();
307 Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
308 Matchers.any(GroupModInput.class),
309 Matchers.any(SwitchConnectionDistinguisher.class));
314 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
315 * updateGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
318 * @throws ExecutionException
319 * @throws InterruptedException
322 public void testUpdateGroup() throws InterruptedException, ExecutionException {
323 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
324 updateGroupOutput.setTransactionId(new TransactionId(new BigInteger("42")));
325 Set<RpcError> errorSet = Collections.emptySet();
326 RpcResult<UpdateGroupOutput> result = Rpcs.getRpcResult(true, updateGroupOutput.build(), errorSet);
328 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
329 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
331 UpdateGroupInputBuilder input = new UpdateGroupInputBuilder();
332 UpdatedGroupBuilder updatedGroupBuilder = new UpdatedGroupBuilder();
333 updatedGroupBuilder.setGroupId(new GroupId(789L));
334 updatedGroupBuilder.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
335 input.setUpdatedGroup(updatedGroupBuilder.build());
337 mdSwitchOF10.updateGroup(input.build()).get();
338 mdSwitchOF13.updateGroup(input.build()).get();
339 Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
340 Matchers.any(GroupModInput.class),
341 Matchers.any(SwitchConnectionDistinguisher.class));
346 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
347 * removeGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
350 * @throws ExecutionException
351 * @throws InterruptedException
354 public void testRemoveGroup() throws InterruptedException, ExecutionException {
355 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
356 updateGroupOutput.setTransactionId(new TransactionId(new BigInteger("42")));
357 Set<RpcError> errorSet = Collections.emptySet();
358 RpcResult<UpdateGroupOutput> result = Rpcs.getRpcResult(true, updateGroupOutput.build(), errorSet);
360 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
361 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
363 RemoveGroupInputBuilder input = new RemoveGroupInputBuilder();
364 input.setGroupId(new GroupId(789L));
365 input.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
367 mdSwitchOF10.removeGroup(input.build()).get();
368 mdSwitchOF13.removeGroup(input.build()).get();
369 Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
370 Matchers.any(GroupModInput.class),
371 Matchers.any(SwitchConnectionDistinguisher.class));
376 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
377 * addMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
380 * @throws ExecutionException
381 * @throws InterruptedException
384 public void testAddMeter() throws InterruptedException, ExecutionException {
385 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
386 updateMeterOutput.setTransactionId(new TransactionId(new BigInteger("42")));
387 Set<RpcError> errorSet = Collections.emptySet();
388 RpcResult<UpdateMeterOutput> result = Rpcs.getRpcResult(true, updateMeterOutput.build(), errorSet);
390 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
391 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
393 AddMeterInputBuilder input = new AddMeterInputBuilder();
394 input.setMeterId(new MeterId(78L));
396 mdSwitchOF10.addMeter(input.build()).get();
397 mdSwitchOF13.addMeter(input.build()).get();
398 Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
399 Matchers.any(MeterModInput.class),
400 Matchers.any(SwitchConnectionDistinguisher.class));
405 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
406 * updateMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
409 * @throws ExecutionException
410 * @throws InterruptedException
413 public void testUpdtateMeter() throws InterruptedException, ExecutionException {
414 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
415 updateMeterOutput.setTransactionId(new TransactionId(new BigInteger("42")));
416 Set<RpcError> errorSet = Collections.emptySet();
417 RpcResult<UpdateMeterOutput> result = Rpcs.getRpcResult(true, updateMeterOutput.build(), errorSet);
419 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
420 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
422 UpdateMeterInputBuilder input = new UpdateMeterInputBuilder();
423 UpdatedMeterBuilder updatedMeterBuilder = new UpdatedMeterBuilder();
424 updatedMeterBuilder.setMeterId(new MeterId(89L));
425 updatedMeterBuilder.setBarrier(false);
426 input.setUpdatedMeter(updatedMeterBuilder.build());
428 mdSwitchOF10.updateMeter(input.build()).get();
429 mdSwitchOF13.updateMeter(input.build()).get();
430 Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
431 Matchers.any(MeterModInput.class),
432 Matchers.any(SwitchConnectionDistinguisher.class));
437 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
438 * removeMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
441 * @throws ExecutionException
442 * @throws InterruptedException
445 public void testRemoveMeter() throws InterruptedException, ExecutionException {
446 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
447 updateMeterOutput.setTransactionId(new TransactionId(new BigInteger("42")));
448 Set<RpcError> errorSet = Collections.emptySet();
449 RpcResult<UpdateMeterOutput> result = Rpcs.getRpcResult(true, updateMeterOutput.build(), errorSet);
451 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
452 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
454 RemoveMeterInputBuilder input = new RemoveMeterInputBuilder();
455 input.setMeterId(new MeterId(89L));
457 mdSwitchOF10.removeMeter(input.build()).get();
458 mdSwitchOF13.removeMeter(input.build()).get();
459 Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
460 Matchers.any(MeterModInput.class),
461 Matchers.any(SwitchConnectionDistinguisher.class));
466 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
467 * getAllGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
468 * GetAllGroupStatisticsInput)}
470 * @throws ExecutionException
471 * @throws InterruptedException
474 public void testGetAllGroupStatistics() throws InterruptedException, ExecutionException {
475 GetAllGroupStatisticsOutputBuilder getAllGroupStatistcsOutput = new GetAllGroupStatisticsOutputBuilder();
476 getAllGroupStatistcsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
477 Set<RpcError> errorSet = Collections.emptySet();
478 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
480 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
481 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
483 GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder();
485 mdSwitchOF10.getAllGroupStatistics(input.build()).get();
486 mdSwitchOF13.getAllGroupStatistics(input.build()).get();
487 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
488 Matchers.any(MultipartRequestInput.class),
489 Matchers.any(SwitchConnectionDistinguisher.class));
494 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
495 * getGroupDescription(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
496 * GetGroupDescriptionInput)}
498 * @throws ExecutionException
499 * @throws InterruptedException
502 public void testGetGroupDescription() throws InterruptedException, ExecutionException {
503 GetGroupDescriptionOutputBuilder getGroupDescOutput = new GetGroupDescriptionOutputBuilder();
504 getGroupDescOutput.setTransactionId(new TransactionId(new BigInteger("42")));
505 Set<RpcError> errorSet = Collections.emptySet();
506 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
508 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
509 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
511 GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder();
513 mdSwitchOF10.getGroupDescription(input.build()).get();
514 mdSwitchOF13.getGroupDescription(input.build()).get();
515 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
516 Matchers.any(MultipartRequestInput.class),
517 Matchers.any(SwitchConnectionDistinguisher.class));
522 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
523 * getGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
524 * GetGroupFeaturesInput)}
526 * @throws ExecutionException
527 * @throws InterruptedException
530 public void testGetGroupFeatures() throws InterruptedException, ExecutionException {
531 GetGroupFeaturesOutputBuilder getGroupFeaturesOutput = new GetGroupFeaturesOutputBuilder();
532 getGroupFeaturesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
533 Set<RpcError> errorSet = Collections.emptySet();
534 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
536 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
537 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
539 GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder();
541 mdSwitchOF10.getGroupFeatures(input.build()).get();
542 mdSwitchOF13.getGroupFeatures(input.build()).get();
543 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
544 Matchers.any(MultipartRequestInput.class),
545 Matchers.any(SwitchConnectionDistinguisher.class));
550 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
551 * getGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
552 * GetGroupStatisticsInput)}
554 * @throws ExecutionException
555 * @throws InterruptedException
557 //TODO GetGroupStatistics why NPE?
559 public void testGetGroupStatistics() throws InterruptedException, ExecutionException {
560 GetGroupStatisticsOutputBuilder getGroupStatsOutput = new GetGroupStatisticsOutputBuilder();
561 getGroupStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
562 Set<RpcError> errorSet = Collections.emptySet();
563 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
565 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
566 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
568 GetGroupStatisticsInputBuilder input = new GetGroupStatisticsInputBuilder();
569 input.setGroupId(new GroupId(42L));
571 mdSwitchOF10.getGroupStatistics(input.build()).get();
572 mdSwitchOF13.getGroupStatistics(input.build()).get();
573 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
574 Matchers.any(MultipartRequestInput.class),
575 Matchers.any(SwitchConnectionDistinguisher.class));
580 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
581 * getAllMeterConfigStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
582 * GetAllMeterConfigStatisticsInput)}
584 * @throws ExecutionException
585 * @throws InterruptedException
588 public void testGetAllMeterConfigStatistics() throws InterruptedException, ExecutionException {
589 GetAllMeterConfigStatisticsOutputBuilder getAllMeterConfigStatsOutput =
590 new GetAllMeterConfigStatisticsOutputBuilder();
591 getAllMeterConfigStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
592 Set<RpcError> errorSet = Collections.emptySet();
593 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
595 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
596 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
598 GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder();
600 mdSwitchOF10.getAllMeterConfigStatistics(input.build()).get();
601 mdSwitchOF13.getAllMeterConfigStatistics(input.build()).get();
602 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
603 Matchers.any(MultipartRequestInput.class),
604 Matchers.any(SwitchConnectionDistinguisher.class));
609 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
610 * getAllMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
611 * GetAllMeterStatisticsInput)}
613 * @throws ExecutionException
614 * @throws InterruptedException
617 public void testGetAllMeterStatistics() throws InterruptedException, ExecutionException {
618 GetAllMeterStatisticsOutputBuilder getAllMeterStatisticsOutput =
619 new GetAllMeterStatisticsOutputBuilder();
620 getAllMeterStatisticsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
621 Set<RpcError> errorSet = Collections.emptySet();
622 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
624 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
625 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
627 GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder();
629 mdSwitchOF10.getAllMeterStatistics(input.build()).get();
630 mdSwitchOF13.getAllMeterStatistics(input.build()).get();
631 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
632 Matchers.any(MultipartRequestInput.class),
633 Matchers.any(SwitchConnectionDistinguisher.class));
638 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
639 * getMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
640 * GetMeterFeaturesInput)}
642 * @throws ExecutionException
643 * @throws InterruptedException
646 public void testGetMeterFeatures() throws InterruptedException, ExecutionException {
647 GetMeterFeaturesOutputBuilder getMeterFeaturesOutput =
648 new GetMeterFeaturesOutputBuilder();
649 getMeterFeaturesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
650 Set<RpcError> errorSet = Collections.emptySet();
651 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
653 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
654 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
656 GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder();
658 mdSwitchOF10.getMeterFeatures(input.build()).get();
659 mdSwitchOF13.getMeterFeatures(input.build()).get();
660 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
661 Matchers.any(MultipartRequestInput.class),
662 Matchers.any(SwitchConnectionDistinguisher.class));
667 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
668 * getMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
669 * GetMeterStatisticsInput)}
671 * @throws ExecutionException
672 * @throws InterruptedException
675 public void testGetMeterStatistics() throws InterruptedException, ExecutionException {
676 GetMeterStatisticsOutputBuilder getMeterStatsOutput = new GetMeterStatisticsOutputBuilder();
677 getMeterStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
678 Set<RpcError> errorSet = Collections.emptySet();
679 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
681 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
682 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
684 GetMeterStatisticsInputBuilder input = new GetMeterStatisticsInputBuilder();
685 input.setMeterId(new MeterId(42L));
687 mdSwitchOF10.getMeterStatistics(input.build()).get();
688 mdSwitchOF13.getMeterStatistics(input.build()).get();
689 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
690 Matchers.any(MultipartRequestInput.class),
691 Matchers.any(SwitchConnectionDistinguisher.class));
696 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
697 * getAllNodeConnectorsStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.
698 * GetAllNodeConnectorsStatisticsInput)}
700 * @throws ExecutionException
701 * @throws InterruptedException
704 public void testGetAllNodeConnectorsStatistics() throws InterruptedException, ExecutionException {
705 GetAllNodeConnectorsStatisticsOutputBuilder getAllNodeConnectorsStatsOutput =
706 new GetAllNodeConnectorsStatisticsOutputBuilder();
707 getAllNodeConnectorsStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
708 Set<RpcError> errorSet = Collections.emptySet();
709 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
711 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
712 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
714 GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder();
716 mdSwitchOF10.getAllNodeConnectorsStatistics(input.build()).get();
717 mdSwitchOF13.getAllNodeConnectorsStatistics(input.build()).get();
718 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
719 Matchers.any(MultipartRequestInput.class),
720 Matchers.any(SwitchConnectionDistinguisher.class));
725 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
726 * getNodeConnectorStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.
727 * GetNodeConnectorStatisticsInput)}
729 * @throws ExecutionException
730 * @throws InterruptedException
733 public void testGetNodeConnectorStatistics() throws InterruptedException, ExecutionException {
734 GetNodeConnectorStatisticsOutputBuilder getNodeConnectorStatsOutput =
735 new GetNodeConnectorStatisticsOutputBuilder();
736 getNodeConnectorStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
737 Set<RpcError> errorSet = Collections.emptySet();
738 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
740 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
741 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
743 GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder();
744 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
746 Mockito.when(features.getVersion()).thenReturn((short)1);
747 mdSwitchOF10.getNodeConnectorStatistics(input.build()).get();
748 Mockito.when(features.getVersion()).thenReturn((short)4);
749 mdSwitchOF13.getNodeConnectorStatistics(input.build()).get();
750 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
751 Matchers.any(MultipartRequestInput.class),
752 Matchers.any(SwitchConnectionDistinguisher.class));
757 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
758 * updatePort(org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.
761 * @throws ExecutionException
762 * @throws InterruptedException
765 public void testUpdatePort() throws InterruptedException, ExecutionException {
766 UpdatePortOutputBuilder updatePortOutput = new UpdatePortOutputBuilder();
767 updatePortOutput.setTransactionId(new TransactionId(new BigInteger("42")));
768 Set<RpcError> errorSet = Collections.emptySet();
769 RpcResult<UpdatePortOutput> result = Rpcs.getRpcResult(true, updatePortOutput.build(), errorSet);
771 messageDispatchService.portMod(Matchers.any(PortModInput.class),
772 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
774 UpdatePortInputBuilder input = new UpdatePortInputBuilder();
776 PortBuilder portBuilder = new PortBuilder();
777 List<Port> ports = new ArrayList<Port>();
778 ports.add(createPort());
779 portBuilder.setPort(ports);
780 UpdatedPortBuilder updatedPortBuilder = new UpdatedPortBuilder();
781 updatedPortBuilder.setPort(portBuilder.build());
782 input.setUpdatedPort(updatedPortBuilder.build());
784 mdSwitchOF10.updatePort(input.build()).get();
785 mdSwitchOF13.updatePort(input.build()).get();
786 Mockito.verify(messageDispatchService, Mockito.times(2)).portMod(
787 Matchers.any(PortModInput.class),
788 Matchers.any(SwitchConnectionDistinguisher.class));
791 private static Port createPort() {
792 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder port =
793 new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder();
795 port.setPortName("TestingPort01");
796 port.setMask(new PortConfig(true, true, true, true));
797 port.setConfiguration(new PortConfig(true, true, true, true));
798 port.setAdvertisedFeatures(new PortFeatures(true, true, true, true,
799 false, false, false, false,
800 true, true, true, true,
801 false, false, false, false));
802 port.setPortNumber(new PortNumber(42L));
803 port.setHardwareAddress(new MacAddress("01:23:45:67:89:ab"));
804 port.setBarrier(true);
805 port.setContainerName("TestContainer");
806 port.setPortModOrder(25L);
807 port.setKey(new PortKey(25L));
813 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
814 * updateTable(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.
817 * @throws ExecutionException
818 * @throws InterruptedException
821 public void testUpdateTable() throws InterruptedException, ExecutionException {
822 UpdateTableOutputBuilder updateTableOutput = new UpdateTableOutputBuilder();
823 updateTableOutput.setTransactionId(new TransactionId(new BigInteger("42")));
824 Set<RpcError> errorSet = Collections.emptySet();
825 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
827 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
828 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
830 UpdateTableInputBuilder input = new UpdateTableInputBuilder();
831 input.setUpdatedTable(createUpdateTable());
833 mdSwitchOF10.updateTable(input.build()).get();
834 mdSwitchOF13.updateTable(input.build()).get();
835 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
836 Matchers.any(MultipartRequestInput.class),
837 Matchers.any(SwitchConnectionDistinguisher.class));
840 private static UpdatedTable createUpdateTable() {
841 UpdatedTableBuilder updatedTableBuilder = new UpdatedTableBuilder();
842 TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
843 tableFeaturesBuilder.setConfig(new TableConfig(true));
844 tableFeaturesBuilder.setKey(new TableFeaturesKey((short) 42));
845 tableFeaturesBuilder.setMaxEntries(42L);
846 tableFeaturesBuilder.setMetadataMatch(new BigInteger("42424242"));
847 tableFeaturesBuilder.setMetadataWrite(new BigInteger("42424242"));
848 tableFeaturesBuilder.setName("testTableFeatures");
849 tableFeaturesBuilder.setTableId((short) 41);
851 TablePropertiesBuilder tablePropertiesBuilder = new TablePropertiesBuilder();
852 TableFeaturePropertiesBuilder tableFeaturePropertiesBuilder = new TableFeaturePropertiesBuilder();
853 tableFeaturePropertiesBuilder.setKey(new TableFeaturePropertiesKey(45));
854 tableFeaturePropertiesBuilder.setOrder(44);
855 tableFeaturePropertiesBuilder.setTableFeaturePropType(new ApplySetfieldBuilder().build());
856 List<TableFeatureProperties> tableFeatureProperties = new ArrayList<TableFeatureProperties>();
857 tableFeatureProperties.add(tableFeaturePropertiesBuilder.build());
858 tablePropertiesBuilder.setTableFeatureProperties(tableFeatureProperties);
860 tableFeaturesBuilder.setTableProperties(tablePropertiesBuilder.build());
861 List<TableFeatures> tableFeatures = new ArrayList<TableFeatures>();
862 tableFeatures.add(tableFeaturesBuilder.build());
863 updatedTableBuilder.setTableFeatures(tableFeatures);
864 return updatedTableBuilder.build();
869 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
870 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
871 * GetAllFlowStatisticsFromFlowTableInput)}
873 * @throws ExecutionException
874 * @throws InterruptedException
877 public void testGetAllFlowStatisticsFromFlowTable() throws InterruptedException, ExecutionException {
878 GetAllFlowStatisticsFromFlowTableOutputBuilder allFlowStatisticsFromFlowTableOutput =
879 new GetAllFlowStatisticsFromFlowTableOutputBuilder();
880 allFlowStatisticsFromFlowTableOutput.setTransactionId(new TransactionId(new BigInteger("42")));
881 Set<RpcError> errorSet = Collections.emptySet();
882 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
884 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
885 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
887 GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder();
888 input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId((short) 42));
890 mdSwitchOF10.getAllFlowStatisticsFromFlowTable(input.build()).get();
891 mdSwitchOF13.getAllFlowStatisticsFromFlowTable(input.build()).get();
892 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
893 Matchers.any(MultipartRequestInput.class),
894 Matchers.any(SwitchConnectionDistinguisher.class));
899 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
900 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
901 * GetAllFlowStatisticsFromFlowTableInput)}
903 * @throws ExecutionException
904 * @throws InterruptedException
907 public void testGetAllFlowsStatisticsFromAllFlowTables() throws InterruptedException, ExecutionException {
908 GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder allFlowStatisticsFromAllFlowTablesOutput =
909 new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
910 allFlowStatisticsFromAllFlowTablesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
911 Set<RpcError> errorSet = Collections.emptySet();
912 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
914 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
915 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
917 GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input =
918 new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
920 mdSwitchOF10.getAllFlowsStatisticsFromAllFlowTables(input.build()).get();
921 mdSwitchOF13.getAllFlowsStatisticsFromAllFlowTables(input.build()).get();
922 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
923 Matchers.any(MultipartRequestInput.class),
924 Matchers.any(SwitchConnectionDistinguisher.class));
929 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
930 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
931 * GetAllFlowStatisticsFromFlowTableInput)}
933 * @throws ExecutionException
934 * @throws InterruptedException
937 public void testGetFlowStatisticsFromFlowTables() throws InterruptedException, ExecutionException {
938 GetFlowStatisticsFromFlowTableOutputBuilder flowStatisticsFromFlowTablesOutput =
939 new GetFlowStatisticsFromFlowTableOutputBuilder();
940 flowStatisticsFromFlowTablesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
941 Set<RpcError> errorSet = Collections.emptySet();
942 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
944 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
945 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
947 GetFlowStatisticsFromFlowTableInputBuilder input =
948 new GetFlowStatisticsFromFlowTableInputBuilder();
949 input.setMatch(createMatch());
951 mdSwitchOF10.getFlowStatisticsFromFlowTable(input.build()).get();
952 mdSwitchOF13.getFlowStatisticsFromFlowTable(input.build()).get();
953 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
954 Matchers.any(MultipartRequestInput.class),
955 Matchers.any(SwitchConnectionDistinguisher.class));
958 private static Match createMatch() {
959 MatchBuilder matchBuilder = new MatchBuilder();
960 EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
961 EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
962 ethernetDestinationBuilder.setAddress(new MacAddress("01:23:45:67:89:ab"));
963 ethernetDestinationBuilder.setMask(new MacAddress("01:23:45:67:89:ab"));
964 ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build());
965 EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
966 ethernetSourceBuilder.setAddress(new MacAddress("01:23:45:67:89:ab"));
967 ethernetSourceBuilder.setMask(new MacAddress("01:23:45:67:89:ab"));
968 ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
969 ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(42L)).build());
970 matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
971 return matchBuilder.build();
976 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
977 * getAggregateFlowStatisticsFromFlowTableForAllFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
978 * GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput)}
980 * @throws ExecutionException
981 * @throws InterruptedException
984 public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws InterruptedException,
986 GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder aggregateFlowStatisticsOutput =
987 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder();
988 aggregateFlowStatisticsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
989 Set<RpcError> errorSet = Collections.emptySet();
990 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
992 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
993 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
995 GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input =
996 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder();
997 input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId((short) 42));
999 mdSwitchOF10.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()).get();
1000 mdSwitchOF13.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()).get();
1001 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1002 Matchers.any(MultipartRequestInput.class),
1003 Matchers.any(SwitchConnectionDistinguisher.class));
1008 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1009 * getAggregateFlowStatisticsFromFlowTableForGivenMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
1010 * GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput)}
1012 * @throws ExecutionException
1013 * @throws InterruptedException
1016 public void testGetAggregateFlowStatisticsFromFlowTableForGivenMatch() throws InterruptedException,
1017 ExecutionException {
1018 GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder aggregateFlowStatisticsForMatchOutput =
1019 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
1020 aggregateFlowStatisticsForMatchOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1021 Set<RpcError> errorSet = Collections.emptySet();
1022 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1024 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1025 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1027 GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder input =
1028 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder();
1029 input.setMatch(createMatch());
1030 input.setCookie(new FlowCookie(new BigInteger("123456")));
1031 input.setCookieMask(new FlowCookie(new BigInteger("123456")));
1032 input.setOutGroup(44L);
1033 input.setOutPort(new BigInteger("12563"));
1035 mdSwitchOF10.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build()).get();
1036 mdSwitchOF13.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build()).get();
1037 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1038 Matchers.any(MultipartRequestInput.class),
1039 Matchers.any(SwitchConnectionDistinguisher.class));
1044 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1045 * getFlowTablesStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.
1046 * GetFlowTablesStatisticsInput)}
1048 * @throws ExecutionException
1049 * @throws InterruptedException
1052 public void testGetFlowTablesStatistics() throws InterruptedException, ExecutionException {
1053 GetFlowTablesStatisticsOutputBuilder flowTableStatisticsOutput =
1054 new GetFlowTablesStatisticsOutputBuilder();
1055 flowTableStatisticsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1056 Set<RpcError> errorSet = Collections.emptySet();
1057 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1059 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1060 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1062 GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder();
1064 mdSwitchOF10.getFlowTablesStatistics(input.build()).get();
1065 mdSwitchOF13.getFlowTablesStatistics(input.build()).get();
1066 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1067 Matchers.any(MultipartRequestInput.class),
1068 Matchers.any(SwitchConnectionDistinguisher.class));
1073 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1074 * getAllQueuesStatisticsFromAllPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1075 * GetAllQueuesStatisticsFromAllPortsInput)}
1077 * @throws ExecutionException
1078 * @throws InterruptedException
1081 public void testGetAllQueuesStatisticsFromAllPorts() throws InterruptedException, ExecutionException {
1082 GetAllQueuesStatisticsFromAllPortsOutputBuilder allQueuesStatisticsAllPortsOutput =
1083 new GetAllQueuesStatisticsFromAllPortsOutputBuilder();
1084 allQueuesStatisticsAllPortsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1085 Set<RpcError> errorSet = Collections.emptySet();
1086 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1088 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1089 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1091 GetAllQueuesStatisticsFromAllPortsInputBuilder input =
1092 new GetAllQueuesStatisticsFromAllPortsInputBuilder();
1094 mdSwitchOF10.getAllQueuesStatisticsFromAllPorts(input.build()).get();
1095 mdSwitchOF13.getAllQueuesStatisticsFromAllPorts(input.build()).get();
1096 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1097 Matchers.any(MultipartRequestInput.class),
1098 Matchers.any(SwitchConnectionDistinguisher.class));
1103 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1104 * getAllQueuesStatisticsFromGivenPort(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1105 * GetAllQueuesStatisticsFromGivenPortInput)}
1107 * @throws ExecutionException
1108 * @throws InterruptedException
1111 public void testGetAllQueuesStatisticsFromGivenPort() throws InterruptedException, ExecutionException {
1112 GetAllQueuesStatisticsFromGivenPortOutputBuilder allQueuesStatisticsGivenPortsOutput =
1113 new GetAllQueuesStatisticsFromGivenPortOutputBuilder();
1114 allQueuesStatisticsGivenPortsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1115 Set<RpcError> errorSet = Collections.emptySet();
1116 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1118 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1119 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1121 GetAllQueuesStatisticsFromGivenPortInputBuilder input =
1122 new GetAllQueuesStatisticsFromGivenPortInputBuilder();
1123 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
1125 Mockito.when(features.getVersion()).thenReturn((short)1);
1126 mdSwitchOF10.getAllQueuesStatisticsFromGivenPort(input.build()).get();
1127 Mockito.when(features.getVersion()).thenReturn((short)4);
1128 mdSwitchOF13.getAllQueuesStatisticsFromGivenPort(input.build()).get();
1129 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1130 Matchers.any(MultipartRequestInput.class),
1131 Matchers.any(SwitchConnectionDistinguisher.class));
1136 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1137 * getQueueStatisticsFromGivenPort(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1138 * GetQueueStatisticsFromGivenPortInput)}
1140 * @throws ExecutionException
1141 * @throws InterruptedException
1144 public void testGetQueueStatisticsFromGivenPort() throws InterruptedException, ExecutionException {
1145 GetQueueStatisticsFromGivenPortOutputBuilder queuesStatisticsGivenPortOutput =
1146 new GetQueueStatisticsFromGivenPortOutputBuilder();
1147 queuesStatisticsGivenPortOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1148 Set<RpcError> errorSet = Collections.emptySet();
1149 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1151 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1152 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1154 GetQueueStatisticsFromGivenPortInputBuilder input =
1155 new GetQueueStatisticsFromGivenPortInputBuilder();
1156 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
1157 input.setQueueId(new QueueId(55L));
1159 Mockito.when(features.getVersion()).thenReturn((short)1);
1160 mdSwitchOF10.getQueueStatisticsFromGivenPort(input.build()).get();
1161 Mockito.when(features.getVersion()).thenReturn((short)4);
1162 mdSwitchOF13.getQueueStatisticsFromGivenPort(input.build()).get();
1163 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1164 Matchers.any(MultipartRequestInput.class),
1165 Matchers.any(SwitchConnectionDistinguisher.class));