Open Kilda Java Documentation
VerificationSendCommandTest.java
Go to the documentation of this file.
1 /* Copyright 2018 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.floodlight.command.flow;
17 
18 import static org.easymock.EasyMock.capture;
19 import static org.easymock.EasyMock.eq;
20 import static org.easymock.EasyMock.expect;
21 import static org.easymock.EasyMock.expectLastCall;
22 import static org.easymock.EasyMock.newCapture;
23 import static org.easymock.EasyMock.replay;
24 import static org.easymock.EasyMock.verify;
25 
30 
31 import org.easymock.Capture;
32 import org.easymock.CaptureType;
33 import org.junit.Assert;
34 import org.junit.Before;
35 import org.junit.Test;
36 import org.projectfloodlight.openflow.protocol.OFFactory;
37 import org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13;
38 
39 import java.util.List;
40 
42  private DataSignature signature;
43 
44  @Before
45  @Override
46  public void setUp() throws Exception {
47  super.setUp();
48  signature = new DataSignature("secret");
49  }
50 
51  @Test
52  public void run() throws OFInstallException {
53  expect(flowVerificationService.getSignature()).andReturn(signature);
55 
56  OFFactory ofFactory = new OFFactoryVer13();
57  expect(sourceSwitch.getOFFactory()).andReturn(ofFactory).anyTimes();
58  replay(sourceSwitch, destSwitch);
59 
62 
63  Capture<List<OfPendingMessage>> capturePushPayload = newCapture(CaptureType.LAST);
64 
65  ioService.push(eq(subject), capture(capturePushPayload));
66  expectLastCall().once();
67  replay(ioService);
68 
69  subject.run();
70 
72 
73  List<OfPendingMessage> pushPayload = capturePushPayload.getValue();
74  Assert.assertTrue("Send operation does not produce packet out message", 0 < pushPayload.size());
75  }
76 }
synchronized void push(org.openkilda.floodlight.command.Command initiator, List< OfPendingMessage > payload)