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 com.google.common.base.Optional;
12 import com.google.common.util.concurrent.CheckedFuture;
13 import com.google.common.util.concurrent.Futures;
14 import com.google.common.util.concurrent.MoreExecutors;
15 import java.math.BigInteger;
16 import java.util.ArrayList;
17 import java.util.List;
18 import java.util.concurrent.ExecutionException;
19 import java.util.concurrent.Executors;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23 import org.mockito.Matchers;
24 import org.mockito.Mock;
25 import org.mockito.Mockito;
26 import org.mockito.runners.MockitoJUnitRunner;
27 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
28 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
29 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
30 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
31 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
32 import org.opendaylight.openflowplugin.api.OFConstants;
33 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
34 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
35 import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
36 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
37 import org.opendaylight.openflowplugin.api.openflow.statistics.MessageSpy;
38 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
39 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
40 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowHashIdMapping;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortKey;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutputBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutputBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInputBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutputBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInputBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutputBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutputBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutputBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInputBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutputBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInputBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInputBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutputBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPortBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutputBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInputBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInputBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTable;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
153 import org.opendaylight.yangtools.yang.binding.DataContainer;
154 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
155 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
156 import org.opendaylight.yangtools.yang.common.RpcResult;
157 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
160 * simple NPE smoke test
162 @RunWith(MockitoJUnitRunner.class)
163 public class ModelDrivenSwitchImplTest {
165 private ModelDrivenSwitchImpl mdSwitchOF10;
166 private ModelDrivenSwitchImpl mdSwitchOF13;
169 private SessionContext context;
171 private ConnectionConductor conductor;
173 private IMessageDispatchService messageDispatchService;
175 private GetFeaturesOutput features;
177 private MessageSpy<DataContainer> messageSpy;
179 private DataBroker dataBroker;
181 private ReadWriteTransaction rwTx;
183 private EntityOwnershipService entityOwnershipService;
186 * @throws java.lang.Exception
189 public void setUp() throws Exception {
190 Mockito.when(context.getPrimaryConductor()).thenReturn(conductor);
191 Mockito.when(context.getMessageDispatchService()).thenReturn(messageDispatchService);
192 Mockito.when(conductor.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0)
193 .thenReturn(OFConstants.OFP_VERSION_1_3);
194 Mockito.when(context.getFeatures()).thenReturn(features);
195 Mockito.when(features.getDatapathId()).thenReturn(BigInteger.valueOf(1));
198 OFSessionUtil.getSessionManager().setRpcPool(MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)));
199 OFSessionUtil.getSessionManager().setMessageSpy(messageSpy);
200 OFSessionUtil.getSessionManager().setDataBroker(dataBroker);
202 CheckedFuture<Optional<FlowHashIdMapping>, ReadFailedException> dummyReadFuture
203 = Futures.<Optional<FlowHashIdMapping>,ReadFailedException>immediateCheckedFuture(Optional.<FlowHashIdMapping>absent());
204 Mockito.when(rwTx.read(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<FlowHashIdMapping>>any())).thenReturn(dummyReadFuture);
205 Mockito.when(dataBroker.newReadWriteTransaction()).thenReturn(rwTx);
208 OpenflowPortsUtil.init();
210 mdSwitchOF10 = new ModelDrivenSwitchImpl(null, null, context);
211 mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context);
216 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#addFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)}
218 * @throws ExecutionException
219 * @throws InterruptedException
222 public void testAddFlow() throws InterruptedException, ExecutionException {
223 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
224 updateFlowOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
225 RpcResult<UpdateFlowOutput> result = RpcResultBuilder.success(updateFlowOutput.build()).build();
227 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
228 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
230 AddFlowInputBuilder input = new AddFlowInputBuilder();
231 input.setMatch(createMatch());
233 Mockito.when(features.getVersion()).thenReturn((short)1);
234 mdSwitchOF10.addFlow(input.build()).get();
235 Mockito.when(features.getVersion()).thenReturn((short)4);
236 mdSwitchOF13.addFlow(input.build()).get();
237 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
238 Matchers.any(FlowModInput.class),
239 Matchers.any(SwitchConnectionDistinguisher.class));
244 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#removeFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)}
246 * @throws ExecutionException
247 * @throws InterruptedException
250 public void testRemoveFlow() throws InterruptedException, ExecutionException {
251 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
252 updateFlowOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
253 RpcResult<UpdateFlowOutput> result = RpcResultBuilder.success(updateFlowOutput.build()).build();
255 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
256 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
258 RemoveFlowInputBuilder input = new RemoveFlowInputBuilder();
259 input.setMatch(createMatch());
261 Mockito.when(features.getVersion()).thenReturn((short)1);
262 mdSwitchOF10.removeFlow(input.build()).get();
263 Mockito.when(features.getVersion()).thenReturn((short)4);
264 mdSwitchOF13.removeFlow(input.build()).get();
265 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
266 Matchers.any(FlowModInput.class),
267 Matchers.any(SwitchConnectionDistinguisher.class));
273 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#updateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)}
275 * @throws ExecutionException
276 * @throws InterruptedException
279 public void testUpdateFlow() throws InterruptedException, ExecutionException {
280 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
281 updateFlowOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
282 RpcResult<UpdateFlowOutput> result = RpcResultBuilder.success(updateFlowOutput.build()).build();
284 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
285 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
287 UpdateFlowInputBuilder input = new UpdateFlowInputBuilder();
288 UpdatedFlowBuilder updatedFlow = new UpdatedFlowBuilder();
289 updatedFlow.setBarrier(false);
290 updatedFlow.setMatch(createMatch());
291 updatedFlow.setPriority(65);
292 updatedFlow.setFlags(new FlowModFlags(true, false, true, false, true));
293 input.setUpdatedFlow(updatedFlow.build());
294 OriginalFlowBuilder originalFlowBuilder = new OriginalFlowBuilder();
295 originalFlowBuilder.setMatch(createMatch());
296 originalFlowBuilder.setPriority(65);
297 originalFlowBuilder.setFlags(new FlowModFlags(true, false, true, false, true));
298 input.setOriginalFlow(originalFlowBuilder.build());
299 KeyedInstanceIdentifier<Flow, FlowKey> dummyIdentifier = InstanceIdentifier.create(Nodes.class)
300 .child(Node.class, new NodeKey(new NodeId("openflow:1")))
301 .augmentation(FlowCapableNode.class)
302 .child(Table.class, new TableKey((short)0))
303 .child(Flow.class, new FlowKey(new FlowId("1")));
304 input.setFlowRef(new FlowRef(dummyIdentifier));
306 Mockito.when(features.getVersion()).thenReturn((short)1);
307 mdSwitchOF10.updateFlow(input.build()).get();
308 Mockito.when(features.getVersion()).thenReturn((short)4);
309 mdSwitchOF13.updateFlow(input.build()).get();
310 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
311 Matchers.any(FlowModInput.class),
312 Matchers.any(SwitchConnectionDistinguisher.class));
317 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
318 * addGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
321 * @throws ExecutionException
322 * @throws InterruptedException
325 public void testAddGroup() throws InterruptedException, ExecutionException {
326 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
327 updateGroupOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
328 RpcResult<UpdateGroupOutput> result = RpcResultBuilder.success(updateGroupOutput.build()).build();
330 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
331 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
333 AddGroupInputBuilder input = new AddGroupInputBuilder();
334 input.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
335 input.setGroupId(new GroupId(789L));
337 mdSwitchOF10.addGroup(input.build()).get();
338 mdSwitchOF13.addGroup(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 * updateGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
350 * @throws ExecutionException
351 * @throws InterruptedException
354 public void testUpdateGroup() throws InterruptedException, ExecutionException {
355 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
356 updateGroupOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
357 RpcResult<UpdateGroupOutput> result = RpcResultBuilder.success(updateGroupOutput.build()).build();
359 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
360 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
362 UpdateGroupInputBuilder input = new UpdateGroupInputBuilder();
363 UpdatedGroupBuilder updatedGroupBuilder = new UpdatedGroupBuilder();
364 updatedGroupBuilder.setGroupId(new GroupId(789L));
365 updatedGroupBuilder.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
366 input.setUpdatedGroup(updatedGroupBuilder.build());
368 mdSwitchOF10.updateGroup(input.build()).get();
369 mdSwitchOF13.updateGroup(input.build()).get();
370 Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
371 Matchers.any(GroupModInput.class),
372 Matchers.any(SwitchConnectionDistinguisher.class));
377 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
378 * removeGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
381 * @throws ExecutionException
382 * @throws InterruptedException
385 public void testRemoveGroup() throws InterruptedException, ExecutionException {
386 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
387 updateGroupOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
388 RpcResult<UpdateGroupOutput> result = RpcResultBuilder.success(updateGroupOutput.build()).build();
390 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
391 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
393 RemoveGroupInputBuilder input = new RemoveGroupInputBuilder();
394 input.setGroupId(new GroupId(789L));
395 input.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
397 mdSwitchOF10.removeGroup(input.build()).get();
398 mdSwitchOF13.removeGroup(input.build()).get();
399 Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
400 Matchers.any(GroupModInput.class),
401 Matchers.any(SwitchConnectionDistinguisher.class));
406 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
407 * addMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
410 * @throws ExecutionException
411 * @throws InterruptedException
414 public void testAddMeter() throws InterruptedException, ExecutionException {
415 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
416 updateMeterOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
417 RpcResult<UpdateMeterOutput> result = RpcResultBuilder.success(updateMeterOutput.build()).build();
419 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
420 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
422 AddMeterInputBuilder input = new AddMeterInputBuilder();
423 input.setMeterId(new MeterId(78L));
425 mdSwitchOF10.addMeter(input.build()).get();
426 mdSwitchOF13.addMeter(input.build()).get();
427 Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
428 Matchers.any(MeterModInput.class),
429 Matchers.any(SwitchConnectionDistinguisher.class));
434 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
435 * updateMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
438 * @throws ExecutionException
439 * @throws InterruptedException
442 public void testUpdtateMeter() throws InterruptedException, ExecutionException {
443 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
444 updateMeterOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
445 RpcResult<UpdateMeterOutput> result = RpcResultBuilder.success(updateMeterOutput.build()).build();
447 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
448 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
450 UpdateMeterInputBuilder input = new UpdateMeterInputBuilder();
451 UpdatedMeterBuilder updatedMeterBuilder = new UpdatedMeterBuilder();
452 updatedMeterBuilder.setMeterId(new MeterId(89L));
453 updatedMeterBuilder.setBarrier(false);
454 input.setUpdatedMeter(updatedMeterBuilder.build());
456 mdSwitchOF10.updateMeter(input.build()).get();
457 mdSwitchOF13.updateMeter(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 * removeMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
469 * @throws ExecutionException
470 * @throws InterruptedException
473 public void testRemoveMeter() throws InterruptedException, ExecutionException {
474 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
475 updateMeterOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
476 RpcResult<UpdateMeterOutput> result = RpcResultBuilder.success(updateMeterOutput.build()).build();
478 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
479 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
481 RemoveMeterInputBuilder input = new RemoveMeterInputBuilder();
482 input.setMeterId(new MeterId(89L));
484 mdSwitchOF10.removeMeter(input.build()).get();
485 mdSwitchOF13.removeMeter(input.build()).get();
486 Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
487 Matchers.any(MeterModInput.class),
488 Matchers.any(SwitchConnectionDistinguisher.class));
493 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
494 * getAllGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
495 * GetAllGroupStatisticsInput)}
497 * @throws ExecutionException
498 * @throws InterruptedException
501 public void testGetAllGroupStatistics() throws InterruptedException, ExecutionException {
502 GetAllGroupStatisticsOutputBuilder getAllGroupStatistcsOutput = new GetAllGroupStatisticsOutputBuilder();
503 getAllGroupStatistcsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
504 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
506 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
507 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
509 GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder();
511 mdSwitchOF10.getAllGroupStatistics(input.build()).get();
512 mdSwitchOF13.getAllGroupStatistics(input.build()).get();
513 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
514 Matchers.any(MultipartRequestInput.class),
515 Matchers.any(SwitchConnectionDistinguisher.class));
520 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
521 * getGroupDescription(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
522 * GetGroupDescriptionInput)}
524 * @throws ExecutionException
525 * @throws InterruptedException
528 public void testGetGroupDescription() throws InterruptedException, ExecutionException {
529 GetGroupDescriptionOutputBuilder getGroupDescOutput = new GetGroupDescriptionOutputBuilder();
530 getGroupDescOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
531 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
533 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
534 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
536 GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder();
538 mdSwitchOF10.getGroupDescription(input.build()).get();
539 mdSwitchOF13.getGroupDescription(input.build()).get();
540 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
541 Matchers.any(MultipartRequestInput.class),
542 Matchers.any(SwitchConnectionDistinguisher.class));
547 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
548 * getGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
549 * GetGroupFeaturesInput)}
551 * @throws ExecutionException
552 * @throws InterruptedException
555 public void testGetGroupFeatures() throws InterruptedException, ExecutionException {
556 GetGroupFeaturesOutputBuilder getGroupFeaturesOutput = new GetGroupFeaturesOutputBuilder();
557 getGroupFeaturesOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
558 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
560 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
561 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
563 GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder();
565 mdSwitchOF10.getGroupFeatures(input.build()).get();
566 mdSwitchOF13.getGroupFeatures(input.build()).get();
567 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
568 Matchers.any(MultipartRequestInput.class),
569 Matchers.any(SwitchConnectionDistinguisher.class));
574 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
575 * getGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
576 * GetGroupStatisticsInput)}
578 * @throws ExecutionException
579 * @throws InterruptedException
581 //TODO GetGroupStatistics why NPE?
583 public void testGetGroupStatistics() throws InterruptedException, ExecutionException {
584 GetGroupStatisticsOutputBuilder getGroupStatsOutput = new GetGroupStatisticsOutputBuilder();
585 getGroupStatsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
586 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
588 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
589 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
591 GetGroupStatisticsInputBuilder input = new GetGroupStatisticsInputBuilder();
592 input.setGroupId(new GroupId(42L));
594 mdSwitchOF10.getGroupStatistics(input.build()).get();
595 mdSwitchOF13.getGroupStatistics(input.build()).get();
596 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
597 Matchers.any(MultipartRequestInput.class),
598 Matchers.any(SwitchConnectionDistinguisher.class));
603 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
604 * getAllMeterConfigStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
605 * GetAllMeterConfigStatisticsInput)}
607 * @throws ExecutionException
608 * @throws InterruptedException
611 public void testGetAllMeterConfigStatistics() throws InterruptedException, ExecutionException {
612 GetAllMeterConfigStatisticsOutputBuilder getAllMeterConfigStatsOutput =
613 new GetAllMeterConfigStatisticsOutputBuilder();
614 getAllMeterConfigStatsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
615 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
617 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
618 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
620 GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder();
622 mdSwitchOF10.getAllMeterConfigStatistics(input.build()).get();
623 mdSwitchOF13.getAllMeterConfigStatistics(input.build()).get();
624 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
625 Matchers.any(MultipartRequestInput.class),
626 Matchers.any(SwitchConnectionDistinguisher.class));
631 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
632 * getAllMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
633 * GetAllMeterStatisticsInput)}
635 * @throws ExecutionException
636 * @throws InterruptedException
639 public void testGetAllMeterStatistics() throws InterruptedException, ExecutionException {
640 GetAllMeterStatisticsOutputBuilder getAllMeterStatisticsOutput =
641 new GetAllMeterStatisticsOutputBuilder();
642 getAllMeterStatisticsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
643 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
645 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
646 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
648 GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder();
650 mdSwitchOF10.getAllMeterStatistics(input.build()).get();
651 mdSwitchOF13.getAllMeterStatistics(input.build()).get();
652 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
653 Matchers.any(MultipartRequestInput.class),
654 Matchers.any(SwitchConnectionDistinguisher.class));
659 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
660 * getMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
661 * GetMeterFeaturesInput)}
663 * @throws ExecutionException
664 * @throws InterruptedException
667 public void testGetMeterFeatures() throws InterruptedException, ExecutionException {
668 GetMeterFeaturesOutputBuilder getMeterFeaturesOutput =
669 new GetMeterFeaturesOutputBuilder();
670 getMeterFeaturesOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
671 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
673 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
674 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
676 GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder();
678 mdSwitchOF10.getMeterFeatures(input.build()).get();
679 mdSwitchOF13.getMeterFeatures(input.build()).get();
680 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
681 Matchers.any(MultipartRequestInput.class),
682 Matchers.any(SwitchConnectionDistinguisher.class));
687 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
688 * getMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
689 * GetMeterStatisticsInput)}
691 * @throws ExecutionException
692 * @throws InterruptedException
695 public void testGetMeterStatistics() throws InterruptedException, ExecutionException {
696 GetMeterStatisticsOutputBuilder getMeterStatsOutput = new GetMeterStatisticsOutputBuilder();
697 getMeterStatsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
698 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
700 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
701 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
703 GetMeterStatisticsInputBuilder input = new GetMeterStatisticsInputBuilder();
704 input.setMeterId(new MeterId(42L));
706 mdSwitchOF10.getMeterStatistics(input.build()).get();
707 mdSwitchOF13.getMeterStatistics(input.build()).get();
708 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
709 Matchers.any(MultipartRequestInput.class),
710 Matchers.any(SwitchConnectionDistinguisher.class));
715 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
716 * getAllNodeConnectorsStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.
717 * GetAllNodeConnectorsStatisticsInput)}
719 * @throws ExecutionException
720 * @throws InterruptedException
723 public void testGetAllNodeConnectorsStatistics() throws InterruptedException, ExecutionException {
724 GetAllNodeConnectorsStatisticsOutputBuilder getAllNodeConnectorsStatsOutput =
725 new GetAllNodeConnectorsStatisticsOutputBuilder();
726 getAllNodeConnectorsStatsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
727 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();;
729 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
730 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
732 GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder();
734 mdSwitchOF10.getAllNodeConnectorsStatistics(input.build()).get();
735 mdSwitchOF13.getAllNodeConnectorsStatistics(input.build()).get();
736 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
737 Matchers.any(MultipartRequestInput.class),
738 Matchers.any(SwitchConnectionDistinguisher.class));
743 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
744 * getNodeConnectorStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.
745 * GetNodeConnectorStatisticsInput)}
747 * @throws ExecutionException
748 * @throws InterruptedException
751 public void testGetNodeConnectorStatistics() throws InterruptedException, ExecutionException {
752 GetNodeConnectorStatisticsOutputBuilder getNodeConnectorStatsOutput =
753 new GetNodeConnectorStatisticsOutputBuilder();
754 getNodeConnectorStatsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
755 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
757 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
758 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
760 GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder();
761 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
763 Mockito.when(features.getVersion()).thenReturn((short)1);
764 mdSwitchOF10.getNodeConnectorStatistics(input.build()).get();
765 Mockito.when(features.getVersion()).thenReturn((short)4);
766 mdSwitchOF13.getNodeConnectorStatistics(input.build()).get();
767 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
768 Matchers.any(MultipartRequestInput.class),
769 Matchers.any(SwitchConnectionDistinguisher.class));
774 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
775 * updatePort(org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.
778 * @throws ExecutionException
779 * @throws InterruptedException
782 public void testUpdatePort() throws InterruptedException, ExecutionException {
783 UpdatePortOutputBuilder updatePortOutput = new UpdatePortOutputBuilder();
784 updatePortOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
785 RpcResult<UpdatePortOutput> result = RpcResultBuilder.success(updatePortOutput.build()).build();
787 messageDispatchService.portMod(Matchers.any(PortModInput.class),
788 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
790 UpdatePortInputBuilder input = new UpdatePortInputBuilder();
792 PortBuilder portBuilder = new PortBuilder();
793 List<Port> ports = new ArrayList<Port>();
794 ports.add(createPort());
795 portBuilder.setPort(ports);
796 UpdatedPortBuilder updatedPortBuilder = new UpdatedPortBuilder();
797 updatedPortBuilder.setPort(portBuilder.build());
798 input.setUpdatedPort(updatedPortBuilder.build());
800 mdSwitchOF10.updatePort(input.build()).get();
801 mdSwitchOF13.updatePort(input.build()).get();
802 Mockito.verify(messageDispatchService, Mockito.times(2)).portMod(
803 Matchers.any(PortModInput.class),
804 Matchers.any(SwitchConnectionDistinguisher.class));
807 private static Port createPort() {
808 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder port =
809 new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder();
811 port.setPortName("TestingPort01");
812 port.setMask(new PortConfig(true, true, true, true));
813 port.setConfiguration(new PortConfig(true, true, true, true));
814 port.setAdvertisedFeatures(new PortFeatures(true, true, true, true,
815 false, false, false, false,
816 true, true, true, true,
817 false, false, false, false));
818 port.setPortNumber(new PortNumberUni(42L));
819 port.setHardwareAddress(new MacAddress("01:23:45:67:89:ab"));
820 port.setBarrier(true);
821 port.setContainerName("TestContainer");
822 port.setPortModOrder(25L);
823 port.setKey(new PortKey(25L));
829 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
830 * updateTable(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.
833 * @throws ExecutionException
834 * @throws InterruptedException
837 public void testUpdateTable() throws InterruptedException, ExecutionException {
838 UpdateTableOutputBuilder updateTableOutput = new UpdateTableOutputBuilder();
839 updateTableOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
840 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
842 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
843 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
845 UpdateTableInputBuilder input = new UpdateTableInputBuilder();
846 input.setUpdatedTable(createUpdateTable());
848 mdSwitchOF10.updateTable(input.build()).get();
849 mdSwitchOF13.updateTable(input.build()).get();
850 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
851 Matchers.any(MultipartRequestInput.class),
852 Matchers.any(SwitchConnectionDistinguisher.class));
855 private static UpdatedTable createUpdateTable() {
856 UpdatedTableBuilder updatedTableBuilder = new UpdatedTableBuilder();
857 TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
858 tableFeaturesBuilder.setConfig(new TableConfig(true));
859 tableFeaturesBuilder.setKey(new TableFeaturesKey((short) 42));
860 tableFeaturesBuilder.setMaxEntries(42L);
861 tableFeaturesBuilder.setMetadataMatch(BigInteger.valueOf(42424242));
862 tableFeaturesBuilder.setMetadataWrite(BigInteger.valueOf(42424242));
863 tableFeaturesBuilder.setName("testTableFeatures");
864 tableFeaturesBuilder.setTableId((short) 41);
866 TablePropertiesBuilder tablePropertiesBuilder = new TablePropertiesBuilder();
867 TableFeaturePropertiesBuilder tableFeaturePropertiesBuilder = new TableFeaturePropertiesBuilder();
868 tableFeaturePropertiesBuilder.setKey(new TableFeaturePropertiesKey(45));
869 tableFeaturePropertiesBuilder.setOrder(44);
870 tableFeaturePropertiesBuilder.setTableFeaturePropType(new ApplySetfieldBuilder().build());
871 List<TableFeatureProperties> tableFeatureProperties = new ArrayList<TableFeatureProperties>();
872 tableFeatureProperties.add(tableFeaturePropertiesBuilder.build());
873 tablePropertiesBuilder.setTableFeatureProperties(tableFeatureProperties);
875 tableFeaturesBuilder.setTableProperties(tablePropertiesBuilder.build());
876 List<TableFeatures> tableFeatures = new ArrayList<TableFeatures>();
877 tableFeatures.add(tableFeaturesBuilder.build());
878 updatedTableBuilder.setTableFeatures(tableFeatures);
879 return updatedTableBuilder.build();
884 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
885 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
886 * GetAllFlowStatisticsFromFlowTableInput)}
888 * @throws ExecutionException
889 * @throws InterruptedException
892 public void testGetAllFlowStatisticsFromFlowTable() throws InterruptedException, ExecutionException {
893 GetAllFlowStatisticsFromFlowTableOutputBuilder allFlowStatisticsFromFlowTableOutput =
894 new GetAllFlowStatisticsFromFlowTableOutputBuilder();
895 allFlowStatisticsFromFlowTableOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
896 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
898 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
899 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
901 GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder();
902 input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId((short) 42));
904 mdSwitchOF10.getAllFlowStatisticsFromFlowTable(input.build()).get();
905 mdSwitchOF13.getAllFlowStatisticsFromFlowTable(input.build()).get();
906 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
907 Matchers.any(MultipartRequestInput.class),
908 Matchers.any(SwitchConnectionDistinguisher.class));
913 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
914 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
915 * GetAllFlowStatisticsFromFlowTableInput)}
917 * @throws ExecutionException
918 * @throws InterruptedException
921 public void testGetAllFlowsStatisticsFromAllFlowTables() throws InterruptedException, ExecutionException {
922 GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder allFlowStatisticsFromAllFlowTablesOutput =
923 new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
924 allFlowStatisticsFromAllFlowTablesOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
925 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
927 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
928 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
930 GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input =
931 new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
933 mdSwitchOF10.getAllFlowsStatisticsFromAllFlowTables(input.build()).get();
934 mdSwitchOF13.getAllFlowsStatisticsFromAllFlowTables(input.build()).get();
935 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
936 Matchers.any(MultipartRequestInput.class),
937 Matchers.any(SwitchConnectionDistinguisher.class));
942 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
943 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
944 * GetAllFlowStatisticsFromFlowTableInput)}
946 * @throws ExecutionException
947 * @throws InterruptedException
950 public void testGetFlowStatisticsFromFlowTables() throws InterruptedException, ExecutionException {
951 GetFlowStatisticsFromFlowTableOutputBuilder flowStatisticsFromFlowTablesOutput =
952 new GetFlowStatisticsFromFlowTableOutputBuilder();
953 flowStatisticsFromFlowTablesOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
954 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
956 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
957 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
959 GetFlowStatisticsFromFlowTableInputBuilder input =
960 new GetFlowStatisticsFromFlowTableInputBuilder();
961 input.setMatch(createMatch());
963 mdSwitchOF10.getFlowStatisticsFromFlowTable(input.build()).get();
964 mdSwitchOF13.getFlowStatisticsFromFlowTable(input.build()).get();
965 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
966 Matchers.any(MultipartRequestInput.class),
967 Matchers.any(SwitchConnectionDistinguisher.class));
970 private static Match createMatch() {
971 MatchBuilder matchBuilder = new MatchBuilder();
972 EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
973 EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
974 ethernetDestinationBuilder.setAddress(new MacAddress("01:23:45:67:89:ab"));
975 ethernetDestinationBuilder.setMask(new MacAddress("01:23:45:67:89:ab"));
976 ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build());
977 EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
978 ethernetSourceBuilder.setAddress(new MacAddress("01:23:45:67:89:ab"));
979 ethernetSourceBuilder.setMask(new MacAddress("01:23:45:67:89:ab"));
980 ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
981 ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(42L)).build());
982 matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
983 return matchBuilder.build();
988 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
989 * getAggregateFlowStatisticsFromFlowTableForAllFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
990 * GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput)}
992 * @throws ExecutionException
993 * @throws InterruptedException
996 public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws InterruptedException,
998 GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder aggregateFlowStatisticsOutput =
999 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder();
1000 aggregateFlowStatisticsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1001 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1003 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1004 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1006 GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input =
1007 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder();
1008 input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId((short) 42));
1010 mdSwitchOF10.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()).get();
1011 mdSwitchOF13.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()).get();
1012 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1013 Matchers.any(MultipartRequestInput.class),
1014 Matchers.any(SwitchConnectionDistinguisher.class));
1019 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1020 * getAggregateFlowStatisticsFromFlowTableForGivenMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
1021 * GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput)}
1023 * @throws ExecutionException
1024 * @throws InterruptedException
1027 public void testGetAggregateFlowStatisticsFromFlowTableForGivenMatch() throws InterruptedException,
1028 ExecutionException {
1029 GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder aggregateFlowStatisticsForMatchOutput =
1030 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
1031 aggregateFlowStatisticsForMatchOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1032 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1034 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1035 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1037 GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder input =
1038 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder();
1039 input.setMatch(createMatch());
1040 input.setCookie(new FlowCookie(BigInteger.valueOf(123456)));
1041 input.setCookieMask(new FlowCookie(BigInteger.valueOf(123456)));
1042 input.setOutGroup(44L);
1043 input.setOutPort(BigInteger.valueOf(12563));
1045 mdSwitchOF10.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build()).get();
1046 mdSwitchOF13.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build()).get();
1047 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1048 Matchers.any(MultipartRequestInput.class),
1049 Matchers.any(SwitchConnectionDistinguisher.class));
1054 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1055 * getFlowTablesStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.
1056 * GetFlowTablesStatisticsInput)}
1058 * @throws ExecutionException
1059 * @throws InterruptedException
1062 public void testGetFlowTablesStatistics() throws InterruptedException, ExecutionException {
1063 GetFlowTablesStatisticsOutputBuilder flowTableStatisticsOutput =
1064 new GetFlowTablesStatisticsOutputBuilder();
1065 flowTableStatisticsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1066 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1068 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1069 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1071 GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder();
1073 mdSwitchOF10.getFlowTablesStatistics(input.build()).get();
1074 mdSwitchOF13.getFlowTablesStatistics(input.build()).get();
1075 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1076 Matchers.any(MultipartRequestInput.class),
1077 Matchers.any(SwitchConnectionDistinguisher.class));
1082 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1083 * getAllQueuesStatisticsFromAllPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1084 * GetAllQueuesStatisticsFromAllPortsInput)}
1086 * @throws ExecutionException
1087 * @throws InterruptedException
1090 public void testGetAllQueuesStatisticsFromAllPorts() throws InterruptedException, ExecutionException {
1091 GetAllQueuesStatisticsFromAllPortsOutputBuilder allQueuesStatisticsAllPortsOutput =
1092 new GetAllQueuesStatisticsFromAllPortsOutputBuilder();
1093 allQueuesStatisticsAllPortsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1094 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1096 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1097 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1099 GetAllQueuesStatisticsFromAllPortsInputBuilder input =
1100 new GetAllQueuesStatisticsFromAllPortsInputBuilder();
1102 mdSwitchOF10.getAllQueuesStatisticsFromAllPorts(input.build()).get();
1103 mdSwitchOF13.getAllQueuesStatisticsFromAllPorts(input.build()).get();
1104 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1105 Matchers.any(MultipartRequestInput.class),
1106 Matchers.any(SwitchConnectionDistinguisher.class));
1111 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1112 * getAllQueuesStatisticsFromGivenPort(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1113 * GetAllQueuesStatisticsFromGivenPortInput)}
1115 * @throws ExecutionException
1116 * @throws InterruptedException
1119 public void testGetAllQueuesStatisticsFromGivenPort() throws InterruptedException, ExecutionException {
1120 GetAllQueuesStatisticsFromGivenPortOutputBuilder allQueuesStatisticsGivenPortsOutput =
1121 new GetAllQueuesStatisticsFromGivenPortOutputBuilder();
1122 allQueuesStatisticsGivenPortsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1123 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1125 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1126 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1128 GetAllQueuesStatisticsFromGivenPortInputBuilder input =
1129 new GetAllQueuesStatisticsFromGivenPortInputBuilder();
1130 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
1132 Mockito.when(features.getVersion()).thenReturn((short)1);
1133 mdSwitchOF10.getAllQueuesStatisticsFromGivenPort(input.build()).get();
1134 Mockito.when(features.getVersion()).thenReturn((short)4);
1135 mdSwitchOF13.getAllQueuesStatisticsFromGivenPort(input.build()).get();
1136 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1137 Matchers.any(MultipartRequestInput.class),
1138 Matchers.any(SwitchConnectionDistinguisher.class));
1143 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1144 * getQueueStatisticsFromGivenPort(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1145 * GetQueueStatisticsFromGivenPortInput)}
1147 * @throws ExecutionException
1148 * @throws InterruptedException
1151 public void testGetQueueStatisticsFromGivenPort() throws InterruptedException, ExecutionException {
1152 GetQueueStatisticsFromGivenPortOutputBuilder queuesStatisticsGivenPortOutput =
1153 new GetQueueStatisticsFromGivenPortOutputBuilder();
1154 queuesStatisticsGivenPortOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1155 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1157 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1158 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1160 GetQueueStatisticsFromGivenPortInputBuilder input =
1161 new GetQueueStatisticsFromGivenPortInputBuilder();
1162 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
1163 input.setQueueId(new QueueId(55L));
1165 Mockito.when(features.getVersion()).thenReturn((short)1);
1166 mdSwitchOF10.getQueueStatisticsFromGivenPort(input.build()).get();
1167 Mockito.when(features.getVersion()).thenReturn((short)4);
1168 mdSwitchOF13.getQueueStatisticsFromGivenPort(input.build()).get();
1169 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1170 Matchers.any(MultipartRequestInput.class),
1171 Matchers.any(SwitchConnectionDistinguisher.class));