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.api.OFConstants;
28 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
29 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
30 import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
31 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
32 import org.opendaylight.openflowplugin.api.statistics.MessageSpy;
33 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
34 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
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.rev150304.TransactionId;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
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.protocol.rev130731.FlowModInput;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInputBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutputBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPortBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutputBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInputBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInputBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTable;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
136 import org.opendaylight.yangtools.yang.binding.DataContainer;
137 import org.opendaylight.yangtools.yang.common.RpcError;
138 import org.opendaylight.yangtools.yang.common.RpcResult;
140 import com.google.common.util.concurrent.Futures;
141 import com.google.common.util.concurrent.MoreExecutors;
144 * simple NPE smoke test
146 @RunWith(MockitoJUnitRunner.class)
147 public class ModelDrivenSwitchImplTest {
149 private ModelDrivenSwitchImpl mdSwitchOF10;
150 private ModelDrivenSwitchImpl mdSwitchOF13;
153 private SessionContext context;
155 private ConnectionConductor conductor;
157 private IMessageDispatchService messageDispatchService;
159 private GetFeaturesOutput features;
161 private MessageSpy<DataContainer> messageSpy;
164 * @throws java.lang.Exception
167 public void setUp() throws Exception {
168 Mockito.when(context.getPrimaryConductor()).thenReturn(conductor);
169 Mockito.when(context.getMessageDispatchService()).thenReturn(messageDispatchService);
170 Mockito.when(conductor.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0)
171 .thenReturn(OFConstants.OFP_VERSION_1_3);
172 Mockito.when(context.getFeatures()).thenReturn(features);
173 Mockito.when(features.getDatapathId()).thenReturn(BigInteger.valueOf(1));
175 OFSessionUtil.getSessionManager().setRpcPool(MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)));
176 OFSessionUtil.getSessionManager().setMessageSpy(messageSpy);
177 OpenflowPortsUtil.init();
179 mdSwitchOF10 = new ModelDrivenSwitchImpl(null, null, context);
180 mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context);
185 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#addFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)}
187 * @throws ExecutionException
188 * @throws InterruptedException
191 public void testAddFlow() throws InterruptedException, ExecutionException {
192 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
193 updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
194 Set<RpcError> errorSet = Collections.emptySet();
195 RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
197 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
198 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
200 AddFlowInputBuilder input = new AddFlowInputBuilder();
201 input.setMatch(createMatch());
203 Mockito.when(features.getVersion()).thenReturn((short)1);
204 mdSwitchOF10.addFlow(input.build()).get();
205 Mockito.when(features.getVersion()).thenReturn((short)4);
206 mdSwitchOF13.addFlow(input.build()).get();
207 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
208 Matchers.any(FlowModInput.class),
209 Matchers.any(SwitchConnectionDistinguisher.class));
214 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#removeFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)}
216 * @throws ExecutionException
217 * @throws InterruptedException
220 public void testRemoveFlow() throws InterruptedException, ExecutionException {
221 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
222 updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
223 Set<RpcError> errorSet = Collections.emptySet();
224 RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
226 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
227 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
229 RemoveFlowInputBuilder input = new RemoveFlowInputBuilder();
230 input.setMatch(createMatch());
232 Mockito.when(features.getVersion()).thenReturn((short)1);
233 mdSwitchOF10.removeFlow(input.build()).get();
234 Mockito.when(features.getVersion()).thenReturn((short)4);
235 mdSwitchOF13.removeFlow(input.build()).get();
236 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
237 Matchers.any(FlowModInput.class),
238 Matchers.any(SwitchConnectionDistinguisher.class));
244 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#updateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)}
246 * @throws ExecutionException
247 * @throws InterruptedException
250 public void testUpdateFlow() throws InterruptedException, ExecutionException {
251 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
252 updateFlowOutput.setTransactionId(new TransactionId(new BigInteger("42")));
253 Set<RpcError> errorSet = Collections.emptySet();
254 RpcResult<UpdateFlowOutput> result = Rpcs.getRpcResult(true, updateFlowOutput.build(), errorSet);
256 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
257 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
259 UpdateFlowInputBuilder input = new UpdateFlowInputBuilder();
260 UpdatedFlowBuilder updatedFlow = new UpdatedFlowBuilder();
261 updatedFlow.setBarrier(false);
262 updatedFlow.setMatch(createMatch());
263 updatedFlow.setPriority(65);
264 updatedFlow.setFlags(new FlowModFlags(true, false, true, false, true));
265 input.setUpdatedFlow(updatedFlow.build());
266 OriginalFlowBuilder originalFlowBuilder = new OriginalFlowBuilder();
267 originalFlowBuilder.setMatch(createMatch());
268 originalFlowBuilder.setPriority(65);
269 originalFlowBuilder.setFlags(new FlowModFlags(true, false, true, false, true));
270 input.setOriginalFlow(originalFlowBuilder.build());
272 Mockito.when(features.getVersion()).thenReturn((short)1);
273 mdSwitchOF10.updateFlow(input.build()).get();
274 Mockito.when(features.getVersion()).thenReturn((short)4);
275 mdSwitchOF13.updateFlow(input.build()).get();
276 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
277 Matchers.any(FlowModInput.class),
278 Matchers.any(SwitchConnectionDistinguisher.class));
283 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
284 * addGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
287 * @throws ExecutionException
288 * @throws InterruptedException
291 public void testAddGroup() throws InterruptedException, ExecutionException {
292 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
293 updateGroupOutput.setTransactionId(new TransactionId(new BigInteger("42")));
294 Set<RpcError> errorSet = Collections.emptySet();
295 RpcResult<UpdateGroupOutput> result = Rpcs.getRpcResult(true, updateGroupOutput.build(), errorSet);
297 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
298 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
300 AddGroupInputBuilder input = new AddGroupInputBuilder();
301 input.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
302 input.setGroupId(new GroupId(789L));
304 mdSwitchOF10.addGroup(input.build()).get();
305 mdSwitchOF13.addGroup(input.build()).get();
306 Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
307 Matchers.any(GroupModInput.class),
308 Matchers.any(SwitchConnectionDistinguisher.class));
313 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
314 * updateGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
317 * @throws ExecutionException
318 * @throws InterruptedException
321 public void testUpdateGroup() throws InterruptedException, ExecutionException {
322 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
323 updateGroupOutput.setTransactionId(new TransactionId(new BigInteger("42")));
324 Set<RpcError> errorSet = Collections.emptySet();
325 RpcResult<UpdateGroupOutput> result = Rpcs.getRpcResult(true, updateGroupOutput.build(), errorSet);
327 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
328 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
330 UpdateGroupInputBuilder input = new UpdateGroupInputBuilder();
331 UpdatedGroupBuilder updatedGroupBuilder = new UpdatedGroupBuilder();
332 updatedGroupBuilder.setGroupId(new GroupId(789L));
333 updatedGroupBuilder.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
334 input.setUpdatedGroup(updatedGroupBuilder.build());
336 mdSwitchOF10.updateGroup(input.build()).get();
337 mdSwitchOF13.updateGroup(input.build()).get();
338 Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
339 Matchers.any(GroupModInput.class),
340 Matchers.any(SwitchConnectionDistinguisher.class));
345 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
346 * removeGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
349 * @throws ExecutionException
350 * @throws InterruptedException
353 public void testRemoveGroup() throws InterruptedException, ExecutionException {
354 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
355 updateGroupOutput.setTransactionId(new TransactionId(new BigInteger("42")));
356 Set<RpcError> errorSet = Collections.emptySet();
357 RpcResult<UpdateGroupOutput> result = Rpcs.getRpcResult(true, updateGroupOutput.build(), errorSet);
359 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
360 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
362 RemoveGroupInputBuilder input = new RemoveGroupInputBuilder();
363 input.setGroupId(new GroupId(789L));
364 input.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
366 mdSwitchOF10.removeGroup(input.build()).get();
367 mdSwitchOF13.removeGroup(input.build()).get();
368 Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
369 Matchers.any(GroupModInput.class),
370 Matchers.any(SwitchConnectionDistinguisher.class));
375 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
376 * addMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
379 * @throws ExecutionException
380 * @throws InterruptedException
383 public void testAddMeter() throws InterruptedException, ExecutionException {
384 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
385 updateMeterOutput.setTransactionId(new TransactionId(new BigInteger("42")));
386 Set<RpcError> errorSet = Collections.emptySet();
387 RpcResult<UpdateMeterOutput> result = Rpcs.getRpcResult(true, updateMeterOutput.build(), errorSet);
389 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
390 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
392 AddMeterInputBuilder input = new AddMeterInputBuilder();
393 input.setMeterId(new MeterId(78L));
395 mdSwitchOF10.addMeter(input.build()).get();
396 mdSwitchOF13.addMeter(input.build()).get();
397 Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
398 Matchers.any(MeterModInput.class),
399 Matchers.any(SwitchConnectionDistinguisher.class));
404 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
405 * updateMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
408 * @throws ExecutionException
409 * @throws InterruptedException
412 public void testUpdtateMeter() throws InterruptedException, ExecutionException {
413 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
414 updateMeterOutput.setTransactionId(new TransactionId(new BigInteger("42")));
415 Set<RpcError> errorSet = Collections.emptySet();
416 RpcResult<UpdateMeterOutput> result = Rpcs.getRpcResult(true, updateMeterOutput.build(), errorSet);
418 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
419 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
421 UpdateMeterInputBuilder input = new UpdateMeterInputBuilder();
422 UpdatedMeterBuilder updatedMeterBuilder = new UpdatedMeterBuilder();
423 updatedMeterBuilder.setMeterId(new MeterId(89L));
424 updatedMeterBuilder.setBarrier(false);
425 input.setUpdatedMeter(updatedMeterBuilder.build());
427 mdSwitchOF10.updateMeter(input.build()).get();
428 mdSwitchOF13.updateMeter(input.build()).get();
429 Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
430 Matchers.any(MeterModInput.class),
431 Matchers.any(SwitchConnectionDistinguisher.class));
436 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
437 * removeMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
440 * @throws ExecutionException
441 * @throws InterruptedException
444 public void testRemoveMeter() throws InterruptedException, ExecutionException {
445 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
446 updateMeterOutput.setTransactionId(new TransactionId(new BigInteger("42")));
447 Set<RpcError> errorSet = Collections.emptySet();
448 RpcResult<UpdateMeterOutput> result = Rpcs.getRpcResult(true, updateMeterOutput.build(), errorSet);
450 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
451 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
453 RemoveMeterInputBuilder input = new RemoveMeterInputBuilder();
454 input.setMeterId(new MeterId(89L));
456 mdSwitchOF10.removeMeter(input.build()).get();
457 mdSwitchOF13.removeMeter(input.build()).get();
458 Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
459 Matchers.any(MeterModInput.class),
460 Matchers.any(SwitchConnectionDistinguisher.class));
465 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
466 * getAllGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
467 * GetAllGroupStatisticsInput)}
469 * @throws ExecutionException
470 * @throws InterruptedException
473 public void testGetAllGroupStatistics() throws InterruptedException, ExecutionException {
474 GetAllGroupStatisticsOutputBuilder getAllGroupStatistcsOutput = new GetAllGroupStatisticsOutputBuilder();
475 getAllGroupStatistcsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
476 Set<RpcError> errorSet = Collections.emptySet();
477 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
479 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
480 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
482 GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder();
484 mdSwitchOF10.getAllGroupStatistics(input.build()).get();
485 mdSwitchOF13.getAllGroupStatistics(input.build()).get();
486 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
487 Matchers.any(MultipartRequestInput.class),
488 Matchers.any(SwitchConnectionDistinguisher.class));
493 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
494 * getGroupDescription(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
495 * GetGroupDescriptionInput)}
497 * @throws ExecutionException
498 * @throws InterruptedException
501 public void testGetGroupDescription() throws InterruptedException, ExecutionException {
502 GetGroupDescriptionOutputBuilder getGroupDescOutput = new GetGroupDescriptionOutputBuilder();
503 getGroupDescOutput.setTransactionId(new TransactionId(new BigInteger("42")));
504 Set<RpcError> errorSet = Collections.emptySet();
505 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
507 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
508 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
510 GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder();
512 mdSwitchOF10.getGroupDescription(input.build()).get();
513 mdSwitchOF13.getGroupDescription(input.build()).get();
514 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
515 Matchers.any(MultipartRequestInput.class),
516 Matchers.any(SwitchConnectionDistinguisher.class));
521 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
522 * getGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
523 * GetGroupFeaturesInput)}
525 * @throws ExecutionException
526 * @throws InterruptedException
529 public void testGetGroupFeatures() throws InterruptedException, ExecutionException {
530 GetGroupFeaturesOutputBuilder getGroupFeaturesOutput = new GetGroupFeaturesOutputBuilder();
531 getGroupFeaturesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
532 Set<RpcError> errorSet = Collections.emptySet();
533 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
535 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
536 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
538 GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder();
540 mdSwitchOF10.getGroupFeatures(input.build()).get();
541 mdSwitchOF13.getGroupFeatures(input.build()).get();
542 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
543 Matchers.any(MultipartRequestInput.class),
544 Matchers.any(SwitchConnectionDistinguisher.class));
549 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
550 * getGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
551 * GetGroupStatisticsInput)}
553 * @throws ExecutionException
554 * @throws InterruptedException
556 //TODO GetGroupStatistics why NPE?
558 public void testGetGroupStatistics() throws InterruptedException, ExecutionException {
559 GetGroupStatisticsOutputBuilder getGroupStatsOutput = new GetGroupStatisticsOutputBuilder();
560 getGroupStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
561 Set<RpcError> errorSet = Collections.emptySet();
562 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
564 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
565 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
567 GetGroupStatisticsInputBuilder input = new GetGroupStatisticsInputBuilder();
568 input.setGroupId(new GroupId(42L));
570 mdSwitchOF10.getGroupStatistics(input.build()).get();
571 mdSwitchOF13.getGroupStatistics(input.build()).get();
572 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
573 Matchers.any(MultipartRequestInput.class),
574 Matchers.any(SwitchConnectionDistinguisher.class));
579 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
580 * getAllMeterConfigStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
581 * GetAllMeterConfigStatisticsInput)}
583 * @throws ExecutionException
584 * @throws InterruptedException
587 public void testGetAllMeterConfigStatistics() throws InterruptedException, ExecutionException {
588 GetAllMeterConfigStatisticsOutputBuilder getAllMeterConfigStatsOutput =
589 new GetAllMeterConfigStatisticsOutputBuilder();
590 getAllMeterConfigStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
591 Set<RpcError> errorSet = Collections.emptySet();
592 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
594 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
595 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
597 GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder();
599 mdSwitchOF10.getAllMeterConfigStatistics(input.build()).get();
600 mdSwitchOF13.getAllMeterConfigStatistics(input.build()).get();
601 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
602 Matchers.any(MultipartRequestInput.class),
603 Matchers.any(SwitchConnectionDistinguisher.class));
608 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
609 * getAllMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
610 * GetAllMeterStatisticsInput)}
612 * @throws ExecutionException
613 * @throws InterruptedException
616 public void testGetAllMeterStatistics() throws InterruptedException, ExecutionException {
617 GetAllMeterStatisticsOutputBuilder getAllMeterStatisticsOutput =
618 new GetAllMeterStatisticsOutputBuilder();
619 getAllMeterStatisticsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
620 Set<RpcError> errorSet = Collections.emptySet();
621 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
623 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
624 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
626 GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder();
628 mdSwitchOF10.getAllMeterStatistics(input.build()).get();
629 mdSwitchOF13.getAllMeterStatistics(input.build()).get();
630 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
631 Matchers.any(MultipartRequestInput.class),
632 Matchers.any(SwitchConnectionDistinguisher.class));
637 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
638 * getMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
639 * GetMeterFeaturesInput)}
641 * @throws ExecutionException
642 * @throws InterruptedException
645 public void testGetMeterFeatures() throws InterruptedException, ExecutionException {
646 GetMeterFeaturesOutputBuilder getMeterFeaturesOutput =
647 new GetMeterFeaturesOutputBuilder();
648 getMeterFeaturesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
649 Set<RpcError> errorSet = Collections.emptySet();
650 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
652 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
653 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
655 GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder();
657 mdSwitchOF10.getMeterFeatures(input.build()).get();
658 mdSwitchOF13.getMeterFeatures(input.build()).get();
659 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
660 Matchers.any(MultipartRequestInput.class),
661 Matchers.any(SwitchConnectionDistinguisher.class));
666 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
667 * getMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
668 * GetMeterStatisticsInput)}
670 * @throws ExecutionException
671 * @throws InterruptedException
674 public void testGetMeterStatistics() throws InterruptedException, ExecutionException {
675 GetMeterStatisticsOutputBuilder getMeterStatsOutput = new GetMeterStatisticsOutputBuilder();
676 getMeterStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
677 Set<RpcError> errorSet = Collections.emptySet();
678 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
680 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
681 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
683 GetMeterStatisticsInputBuilder input = new GetMeterStatisticsInputBuilder();
684 input.setMeterId(new MeterId(42L));
686 mdSwitchOF10.getMeterStatistics(input.build()).get();
687 mdSwitchOF13.getMeterStatistics(input.build()).get();
688 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
689 Matchers.any(MultipartRequestInput.class),
690 Matchers.any(SwitchConnectionDistinguisher.class));
695 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
696 * getAllNodeConnectorsStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.
697 * GetAllNodeConnectorsStatisticsInput)}
699 * @throws ExecutionException
700 * @throws InterruptedException
703 public void testGetAllNodeConnectorsStatistics() throws InterruptedException, ExecutionException {
704 GetAllNodeConnectorsStatisticsOutputBuilder getAllNodeConnectorsStatsOutput =
705 new GetAllNodeConnectorsStatisticsOutputBuilder();
706 getAllNodeConnectorsStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
707 Set<RpcError> errorSet = Collections.emptySet();
708 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
710 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
711 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
713 GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder();
715 mdSwitchOF10.getAllNodeConnectorsStatistics(input.build()).get();
716 mdSwitchOF13.getAllNodeConnectorsStatistics(input.build()).get();
717 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
718 Matchers.any(MultipartRequestInput.class),
719 Matchers.any(SwitchConnectionDistinguisher.class));
724 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
725 * getNodeConnectorStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.
726 * GetNodeConnectorStatisticsInput)}
728 * @throws ExecutionException
729 * @throws InterruptedException
732 public void testGetNodeConnectorStatistics() throws InterruptedException, ExecutionException {
733 GetNodeConnectorStatisticsOutputBuilder getNodeConnectorStatsOutput =
734 new GetNodeConnectorStatisticsOutputBuilder();
735 getNodeConnectorStatsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
736 Set<RpcError> errorSet = Collections.emptySet();
737 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
739 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
740 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
742 GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder();
743 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
745 Mockito.when(features.getVersion()).thenReturn((short)1);
746 mdSwitchOF10.getNodeConnectorStatistics(input.build()).get();
747 Mockito.when(features.getVersion()).thenReturn((short)4);
748 mdSwitchOF13.getNodeConnectorStatistics(input.build()).get();
749 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
750 Matchers.any(MultipartRequestInput.class),
751 Matchers.any(SwitchConnectionDistinguisher.class));
756 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
757 * updatePort(org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.
760 * @throws ExecutionException
761 * @throws InterruptedException
764 public void testUpdatePort() throws InterruptedException, ExecutionException {
765 UpdatePortOutputBuilder updatePortOutput = new UpdatePortOutputBuilder();
766 updatePortOutput.setTransactionId(new TransactionId(new BigInteger("42")));
767 Set<RpcError> errorSet = Collections.emptySet();
768 RpcResult<UpdatePortOutput> result = Rpcs.getRpcResult(true, updatePortOutput.build(), errorSet);
770 messageDispatchService.portMod(Matchers.any(PortModInput.class),
771 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
773 UpdatePortInputBuilder input = new UpdatePortInputBuilder();
775 PortBuilder portBuilder = new PortBuilder();
776 List<Port> ports = new ArrayList<Port>();
777 ports.add(createPort());
778 portBuilder.setPort(ports);
779 UpdatedPortBuilder updatedPortBuilder = new UpdatedPortBuilder();
780 updatedPortBuilder.setPort(portBuilder.build());
781 input.setUpdatedPort(updatedPortBuilder.build());
783 mdSwitchOF10.updatePort(input.build()).get();
784 mdSwitchOF13.updatePort(input.build()).get();
785 Mockito.verify(messageDispatchService, Mockito.times(2)).portMod(
786 Matchers.any(PortModInput.class),
787 Matchers.any(SwitchConnectionDistinguisher.class));
790 private static Port createPort() {
791 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder port =
792 new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder();
794 port.setPortName("TestingPort01");
795 port.setMask(new PortConfig(true, true, true, true));
796 port.setConfiguration(new PortConfig(true, true, true, true));
797 port.setAdvertisedFeatures(new PortFeatures(true, true, true, true,
798 false, false, false, false,
799 true, true, true, true,
800 false, false, false, false));
801 port.setPortNumber(new PortNumberUni(42L));
802 port.setHardwareAddress(new MacAddress("01:23:45:67:89:ab"));
803 port.setBarrier(true);
804 port.setContainerName("TestContainer");
805 port.setPortModOrder(25L);
806 port.setKey(new PortKey(25L));
812 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
813 * updateTable(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.
816 * @throws ExecutionException
817 * @throws InterruptedException
820 public void testUpdateTable() throws InterruptedException, ExecutionException {
821 UpdateTableOutputBuilder updateTableOutput = new UpdateTableOutputBuilder();
822 updateTableOutput.setTransactionId(new TransactionId(new BigInteger("42")));
823 Set<RpcError> errorSet = Collections.emptySet();
824 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
826 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
827 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
829 UpdateTableInputBuilder input = new UpdateTableInputBuilder();
830 input.setUpdatedTable(createUpdateTable());
832 mdSwitchOF10.updateTable(input.build()).get();
833 mdSwitchOF13.updateTable(input.build()).get();
834 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
835 Matchers.any(MultipartRequestInput.class),
836 Matchers.any(SwitchConnectionDistinguisher.class));
839 private static UpdatedTable createUpdateTable() {
840 UpdatedTableBuilder updatedTableBuilder = new UpdatedTableBuilder();
841 TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
842 tableFeaturesBuilder.setConfig(new TableConfig(true));
843 tableFeaturesBuilder.setKey(new TableFeaturesKey((short) 42));
844 tableFeaturesBuilder.setMaxEntries(42L);
845 tableFeaturesBuilder.setMetadataMatch(new BigInteger("42424242"));
846 tableFeaturesBuilder.setMetadataWrite(new BigInteger("42424242"));
847 tableFeaturesBuilder.setName("testTableFeatures");
848 tableFeaturesBuilder.setTableId((short) 41);
850 TablePropertiesBuilder tablePropertiesBuilder = new TablePropertiesBuilder();
851 TableFeaturePropertiesBuilder tableFeaturePropertiesBuilder = new TableFeaturePropertiesBuilder();
852 tableFeaturePropertiesBuilder.setKey(new TableFeaturePropertiesKey(45));
853 tableFeaturePropertiesBuilder.setOrder(44);
854 tableFeaturePropertiesBuilder.setTableFeaturePropType(new ApplySetfieldBuilder().build());
855 List<TableFeatureProperties> tableFeatureProperties = new ArrayList<TableFeatureProperties>();
856 tableFeatureProperties.add(tableFeaturePropertiesBuilder.build());
857 tablePropertiesBuilder.setTableFeatureProperties(tableFeatureProperties);
859 tableFeaturesBuilder.setTableProperties(tablePropertiesBuilder.build());
860 List<TableFeatures> tableFeatures = new ArrayList<TableFeatures>();
861 tableFeatures.add(tableFeaturesBuilder.build());
862 updatedTableBuilder.setTableFeatures(tableFeatures);
863 return updatedTableBuilder.build();
868 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
869 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
870 * GetAllFlowStatisticsFromFlowTableInput)}
872 * @throws ExecutionException
873 * @throws InterruptedException
876 public void testGetAllFlowStatisticsFromFlowTable() throws InterruptedException, ExecutionException {
877 GetAllFlowStatisticsFromFlowTableOutputBuilder allFlowStatisticsFromFlowTableOutput =
878 new GetAllFlowStatisticsFromFlowTableOutputBuilder();
879 allFlowStatisticsFromFlowTableOutput.setTransactionId(new TransactionId(new BigInteger("42")));
880 Set<RpcError> errorSet = Collections.emptySet();
881 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
883 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
884 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
886 GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder();
887 input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId((short) 42));
889 mdSwitchOF10.getAllFlowStatisticsFromFlowTable(input.build()).get();
890 mdSwitchOF13.getAllFlowStatisticsFromFlowTable(input.build()).get();
891 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
892 Matchers.any(MultipartRequestInput.class),
893 Matchers.any(SwitchConnectionDistinguisher.class));
898 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
899 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
900 * GetAllFlowStatisticsFromFlowTableInput)}
902 * @throws ExecutionException
903 * @throws InterruptedException
906 public void testGetAllFlowsStatisticsFromAllFlowTables() throws InterruptedException, ExecutionException {
907 GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder allFlowStatisticsFromAllFlowTablesOutput =
908 new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
909 allFlowStatisticsFromAllFlowTablesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
910 Set<RpcError> errorSet = Collections.emptySet();
911 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
913 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
914 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
916 GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input =
917 new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
919 mdSwitchOF10.getAllFlowsStatisticsFromAllFlowTables(input.build()).get();
920 mdSwitchOF13.getAllFlowsStatisticsFromAllFlowTables(input.build()).get();
921 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
922 Matchers.any(MultipartRequestInput.class),
923 Matchers.any(SwitchConnectionDistinguisher.class));
928 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
929 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
930 * GetAllFlowStatisticsFromFlowTableInput)}
932 * @throws ExecutionException
933 * @throws InterruptedException
936 public void testGetFlowStatisticsFromFlowTables() throws InterruptedException, ExecutionException {
937 GetFlowStatisticsFromFlowTableOutputBuilder flowStatisticsFromFlowTablesOutput =
938 new GetFlowStatisticsFromFlowTableOutputBuilder();
939 flowStatisticsFromFlowTablesOutput.setTransactionId(new TransactionId(new BigInteger("42")));
940 Set<RpcError> errorSet = Collections.emptySet();
941 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
943 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
944 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
946 GetFlowStatisticsFromFlowTableInputBuilder input =
947 new GetFlowStatisticsFromFlowTableInputBuilder();
948 input.setMatch(createMatch());
950 mdSwitchOF10.getFlowStatisticsFromFlowTable(input.build()).get();
951 mdSwitchOF13.getFlowStatisticsFromFlowTable(input.build()).get();
952 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
953 Matchers.any(MultipartRequestInput.class),
954 Matchers.any(SwitchConnectionDistinguisher.class));
957 private static Match createMatch() {
958 MatchBuilder matchBuilder = new MatchBuilder();
959 EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
960 EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
961 ethernetDestinationBuilder.setAddress(new MacAddress("01:23:45:67:89:ab"));
962 ethernetDestinationBuilder.setMask(new MacAddress("01:23:45:67:89:ab"));
963 ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build());
964 EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
965 ethernetSourceBuilder.setAddress(new MacAddress("01:23:45:67:89:ab"));
966 ethernetSourceBuilder.setMask(new MacAddress("01:23:45:67:89:ab"));
967 ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
968 ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(42L)).build());
969 matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
970 return matchBuilder.build();
975 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
976 * getAggregateFlowStatisticsFromFlowTableForAllFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
977 * GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput)}
979 * @throws ExecutionException
980 * @throws InterruptedException
983 public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws InterruptedException,
985 GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder aggregateFlowStatisticsOutput =
986 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder();
987 aggregateFlowStatisticsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
988 Set<RpcError> errorSet = Collections.emptySet();
989 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
991 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
992 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
994 GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input =
995 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder();
996 input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId((short) 42));
998 mdSwitchOF10.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()).get();
999 mdSwitchOF13.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()).get();
1000 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1001 Matchers.any(MultipartRequestInput.class),
1002 Matchers.any(SwitchConnectionDistinguisher.class));
1007 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1008 * getAggregateFlowStatisticsFromFlowTableForGivenMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
1009 * GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput)}
1011 * @throws ExecutionException
1012 * @throws InterruptedException
1015 public void testGetAggregateFlowStatisticsFromFlowTableForGivenMatch() throws InterruptedException,
1016 ExecutionException {
1017 GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder aggregateFlowStatisticsForMatchOutput =
1018 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
1019 aggregateFlowStatisticsForMatchOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1020 Set<RpcError> errorSet = Collections.emptySet();
1021 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1023 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1024 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1026 GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder input =
1027 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder();
1028 input.setMatch(createMatch());
1029 input.setCookie(new FlowCookie(new BigInteger("123456")));
1030 input.setCookieMask(new FlowCookie(new BigInteger("123456")));
1031 input.setOutGroup(44L);
1032 input.setOutPort(new BigInteger("12563"));
1034 mdSwitchOF10.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build()).get();
1035 mdSwitchOF13.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build()).get();
1036 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1037 Matchers.any(MultipartRequestInput.class),
1038 Matchers.any(SwitchConnectionDistinguisher.class));
1043 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1044 * getFlowTablesStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.
1045 * GetFlowTablesStatisticsInput)}
1047 * @throws ExecutionException
1048 * @throws InterruptedException
1051 public void testGetFlowTablesStatistics() throws InterruptedException, ExecutionException {
1052 GetFlowTablesStatisticsOutputBuilder flowTableStatisticsOutput =
1053 new GetFlowTablesStatisticsOutputBuilder();
1054 flowTableStatisticsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1055 Set<RpcError> errorSet = Collections.emptySet();
1056 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1058 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1059 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1061 GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder();
1063 mdSwitchOF10.getFlowTablesStatistics(input.build()).get();
1064 mdSwitchOF13.getFlowTablesStatistics(input.build()).get();
1065 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1066 Matchers.any(MultipartRequestInput.class),
1067 Matchers.any(SwitchConnectionDistinguisher.class));
1072 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1073 * getAllQueuesStatisticsFromAllPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1074 * GetAllQueuesStatisticsFromAllPortsInput)}
1076 * @throws ExecutionException
1077 * @throws InterruptedException
1080 public void testGetAllQueuesStatisticsFromAllPorts() throws InterruptedException, ExecutionException {
1081 GetAllQueuesStatisticsFromAllPortsOutputBuilder allQueuesStatisticsAllPortsOutput =
1082 new GetAllQueuesStatisticsFromAllPortsOutputBuilder();
1083 allQueuesStatisticsAllPortsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1084 Set<RpcError> errorSet = Collections.emptySet();
1085 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1087 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1088 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1090 GetAllQueuesStatisticsFromAllPortsInputBuilder input =
1091 new GetAllQueuesStatisticsFromAllPortsInputBuilder();
1093 mdSwitchOF10.getAllQueuesStatisticsFromAllPorts(input.build()).get();
1094 mdSwitchOF13.getAllQueuesStatisticsFromAllPorts(input.build()).get();
1095 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1096 Matchers.any(MultipartRequestInput.class),
1097 Matchers.any(SwitchConnectionDistinguisher.class));
1102 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1103 * getAllQueuesStatisticsFromGivenPort(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1104 * GetAllQueuesStatisticsFromGivenPortInput)}
1106 * @throws ExecutionException
1107 * @throws InterruptedException
1110 public void testGetAllQueuesStatisticsFromGivenPort() throws InterruptedException, ExecutionException {
1111 GetAllQueuesStatisticsFromGivenPortOutputBuilder allQueuesStatisticsGivenPortsOutput =
1112 new GetAllQueuesStatisticsFromGivenPortOutputBuilder();
1113 allQueuesStatisticsGivenPortsOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1114 Set<RpcError> errorSet = Collections.emptySet();
1115 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1117 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1118 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1120 GetAllQueuesStatisticsFromGivenPortInputBuilder input =
1121 new GetAllQueuesStatisticsFromGivenPortInputBuilder();
1122 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
1124 Mockito.when(features.getVersion()).thenReturn((short)1);
1125 mdSwitchOF10.getAllQueuesStatisticsFromGivenPort(input.build()).get();
1126 Mockito.when(features.getVersion()).thenReturn((short)4);
1127 mdSwitchOF13.getAllQueuesStatisticsFromGivenPort(input.build()).get();
1128 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1129 Matchers.any(MultipartRequestInput.class),
1130 Matchers.any(SwitchConnectionDistinguisher.class));
1135 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1136 * getQueueStatisticsFromGivenPort(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1137 * GetQueueStatisticsFromGivenPortInput)}
1139 * @throws ExecutionException
1140 * @throws InterruptedException
1143 public void testGetQueueStatisticsFromGivenPort() throws InterruptedException, ExecutionException {
1144 GetQueueStatisticsFromGivenPortOutputBuilder queuesStatisticsGivenPortOutput =
1145 new GetQueueStatisticsFromGivenPortOutputBuilder();
1146 queuesStatisticsGivenPortOutput.setTransactionId(new TransactionId(new BigInteger("42")));
1147 Set<RpcError> errorSet = Collections.emptySet();
1148 RpcResult<Void> result = Rpcs.getRpcResult(true, null, errorSet);
1150 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1151 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1153 GetQueueStatisticsFromGivenPortInputBuilder input =
1154 new GetQueueStatisticsFromGivenPortInputBuilder();
1155 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
1156 input.setQueueId(new QueueId(55L));
1158 Mockito.when(features.getVersion()).thenReturn((short)1);
1159 mdSwitchOF10.getQueueStatisticsFromGivenPort(input.build()).get();
1160 Mockito.when(features.getVersion()).thenReturn((short)4);
1161 mdSwitchOF13.getQueueStatisticsFromGivenPort(input.build()).get();
1162 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1163 Matchers.any(MultipartRequestInput.class),
1164 Matchers.any(SwitchConnectionDistinguisher.class));