本文整理汇总了Java中org.easymock.Capture.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Capture.getValue方法的具体用法?Java Capture.getValue怎么用?Java Capture.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.easymock.Capture
的用法示例。
在下文中一共展示了Capture.getValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSingleMessageWrite
import org.easymock.Capture; //导入方法依赖的package包/类
/** write a packetOut, which is not buffered */
@Test(timeout = 5000)
public void testSingleMessageWrite() throws InterruptedException, ExecutionException {
Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();
OFPacketOut packetOut = factory.buildPacketOut()
.setData(new byte[] { 0x01, 0x02, 0x03, 0x04 })
.setActions(ImmutableList.<OFAction>of( factory.actions().output(OFPort.of(1), 0)))
.build();
conn.write(packetOut);
eventLoop.runTasks();
assertThat("Write should have been flushed", cMsgList.hasCaptured(), equalTo(true));
List<OFMessage> value = cMsgList.getValue();
logger.info("Captured channel write: "+value);
assertThat("Should have captured MsgList", cMsgList.getValue(),
Matchers.<OFMessage> contains(packetOut));
}
示例2: testMessageWriteList
import org.easymock.Capture; //导入方法依赖的package包/类
/** write a list of messages */
@Test(timeout = 5000)
public void testMessageWriteList() throws InterruptedException, ExecutionException {
Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();
OFHello hello = factory.hello(ImmutableList.<OFHelloElem>of());
OFPacketOut packetOut = factory.buildPacketOut()
.setData(new byte[] { 0x01, 0x02, 0x03, 0x04 })
.setActions(ImmutableList.<OFAction>of( factory.actions().output(OFPort.of(1), 0)))
.build();
conn.write(ImmutableList.of(hello, packetOut));
eventLoop.runTasks();
assertThat("Write should have been written", cMsgList.hasCaptured(), equalTo(true));
List<OFMessage> value = cMsgList.getValue();
logger.info("Captured channel write: "+value);
assertThat("Should have captured MsgList", cMsgList.getValue(),
Matchers.<OFMessage> contains(hello, packetOut));
}
示例3: testSingleMessageWrite
import org.easymock.Capture; //导入方法依赖的package包/类
/** write a packetOut, which is buffered */
@Test(timeout = 5000)
public void testSingleMessageWrite() throws InterruptedException, ExecutionException {
Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();
OFPacketOut packetOut = factory.buildPacketOut()
.setData(new byte[] { 0x01, 0x02, 0x03, 0x04 })
.setActions(ImmutableList.<OFAction>of( factory.actions().output(OFPort.of(1), 0)))
.build();
conn.write(packetOut);
assertThat("Write should have been flushed", cMsgList.hasCaptured(), equalTo(true));
List<OFMessage> value = cMsgList.getValue();
logger.info("Captured channel write: "+value);
assertThat("Should have captured MsgList", cMsgList.getValue(),
Matchers.<OFMessage> contains(packetOut));
}
示例4: testMessageWriteList
import org.easymock.Capture; //导入方法依赖的package包/类
/** write a list of messages */
@Test(timeout = 5000)
public void testMessageWriteList() throws InterruptedException, ExecutionException {
Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();
OFHello hello = factory.hello(ImmutableList.<OFHelloElem>of());
OFPacketOut packetOut = factory.buildPacketOut()
.setData(new byte[] { 0x01, 0x02, 0x03, 0x04 })
.setActions(ImmutableList.<OFAction>of( factory.actions().output(OFPort.of(1), 0)))
.build();
conn.write(ImmutableList.of(hello, packetOut));
assertThat("Write should have been written", cMsgList.hasCaptured(), equalTo(true));
List<OFMessage> value = cMsgList.getValue();
logger.info("Captured channel write: "+value);
assertThat("Should have captured MsgList", cMsgList.getValue(),
Matchers.<OFMessage> contains(hello, packetOut));
}
示例5: deleteFlow
import org.easymock.Capture; //导入方法依赖的package包/类
@Test
public void deleteFlow() throws Exception {
Capture<OFFlowMod> capture = prepareForInstallTest();
switchManager.deleteFlow(dpid, cookieHex, cookie);
final OFFlowMod actual = capture.getValue();
assertEquals(OFFlowModCommand.DELETE, actual.getCommand());
assertEquals(Long.valueOf(cookieHex, 16).longValue(), actual.getCookie().getValue());
assertEquals(SwitchManager.NON_SYSTEM_MASK, actual.getCookieMask());
}
示例6: deleteMeter
import org.easymock.Capture; //导入方法依赖的package包/类
@Test
public void deleteMeter() {
final Capture<OFMeterMod> capture = prepareForMeterTest();
switchManager.deleteMeter(dpid, meterId);
final OFMeterMod meterMod = capture.getValue();
assertEquals(meterMod.getCommand(), OFMeterModCommand.DELETE);
assertEquals(meterMod.getMeterId(), meterId);
}
示例7: assertExpireTime
import org.easymock.Capture; //导入方法依赖的package包/类
private void assertExpireTime(long expectedExpire, Capture<TwoWayChannelMessage> initiateCapture) {
final TwoWayChannelMessage response = initiateCapture.getValue();
final MessageType type = response.getType();
assertEquals("Wrong type " + type, MessageType.INITIATE, type);
final long actualExpire = response.getInitiate().getExpireTimeSecs();
assertTrue("Expire time too small " + expectedExpire + " > " + actualExpire, expectedExpire <= actualExpire);
assertTrue("Expire time too large " + expectedExpire + "<" + actualExpire, expectedExpire >= actualExpire);
}
示例8: testFloodNoBufferId
import org.easymock.Capture; //导入方法依赖的package包/类
@Test
public void testFloodNoBufferId() throws Exception {
// Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
EasyMock.expect(mockSwitch.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
// build our expected flooded packetOut
OFActionOutput ao = OFFactories.getFactory(OFVersion.OF_13).actions().buildOutput().setPort(OFPort.FLOOD).build();
List<OFAction> al = new ArrayList<OFAction>();
al.add(ao);
OFPacketOut po = OFFactories.getFactory(OFVersion.OF_13).buildPacketOut()
.setActions(al)
.setBufferId(OFBufferId.NO_BUFFER)
.setXid(1)
.setInPort(OFPort.of(1))
.setData(this.testPacketSerialized).build();
Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
expect(mockSwitch.write(capture(wc1))).andReturn(true).anyTimes();
// Start recording the replay on the mocks
replay(mockSwitch);
// Get the listener and trigger the packet in
IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
OFType.PACKET_IN).get(0);
listener.receive(mockSwitch, this.packetIn,
parseAndAnnotate(this.packetIn));
// Verify the replay matched our expectations
verify(mockSwitch);
assertTrue(wc1.hasCaptured());
OFMessage m = wc1.getValue();
assertTrue(OFMessageUtils.equalsIgnoreXid(m, po));
}
示例9: testFloodBufferId
import org.easymock.Capture; //导入方法依赖的package包/类
@Test
public void testFloodBufferId() throws Exception {
MockFloodlightProvider mockFloodlightProvider = getMockFloodlightProvider();
this.packetIn = this.packetIn.createBuilder()
.setBufferId(OFBufferId.of(10))
.setXid(1)
.build();
OFActionOutput ao = OFFactories.getFactory(OFVersion.OF_13).actions().buildOutput().setPort(OFPort.FLOOD).build();
List<OFAction> al = new ArrayList<OFAction>();
al.add(ao);
// build our expected flooded packetOut
OFPacketOut po = OFFactories.getFactory(OFVersion.OF_13).buildPacketOut()
.setActions(al)
.setXid(1)
.setBufferId(OFBufferId.of(10))
.setInPort(OFPort.of(1))
.build();
// Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
EasyMock.expect(mockSwitch.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
Capture<OFPacketOut> wc1 = new Capture<OFPacketOut>(CaptureType.ALL);
expect(mockSwitch.write(capture(wc1))).andReturn(true).anyTimes();
// Start recording the replay on the mocks
replay(mockSwitch);
// Get the listener and trigger the packet in
IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
OFType.PACKET_IN).get(0);
listener.receive(mockSwitch, this.packetIn,
parseAndAnnotate(this.packetIn));
// Verify the replay matched our expectations
verify(mockSwitch);
assertTrue(wc1.hasCaptured());
OFMessage m = wc1.getValue();
assertEquals(po, m);
}
示例10: testFloodNoBufferId
import org.easymock.Capture; //导入方法依赖的package包/类
@Test
public void testFloodNoBufferId() throws Exception {
// Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
EasyMock.expect(mockSwitch.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
// build our expected flooded packetOut
OFActionOutput ao = OFFactories.getFactory(OFVersion.OF_13).actions().buildOutput().setPort(OFPort.FLOOD).build();
List<OFAction> al = new ArrayList<OFAction>();
al.add(ao);
OFPacketOut po = OFFactories.getFactory(OFVersion.OF_13).buildPacketOut()
.setActions(al)
.setBufferId(OFBufferId.NO_BUFFER)
.setXid(1)
.setInPort(OFPort.of(1))
.setData(this.testPacketSerialized).build();
Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
mockSwitch.write(capture(wc1));
// Start recording the replay on the mocks
replay(mockSwitch);
// Get the listener and trigger the packet in
IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
OFType.PACKET_IN).get(0);
listener.receive(mockSwitch, this.packetIn,
parseAndAnnotate(this.packetIn));
// Verify the replay matched our expectations
verify(mockSwitch);
assertTrue(wc1.hasCaptured());
OFMessage m = wc1.getValue();
assertTrue(OFMessageUtils.equalsIgnoreXid(m, po));
}
示例11: testFloodBufferId
import org.easymock.Capture; //导入方法依赖的package包/类
@Test
public void testFloodBufferId() throws Exception {
MockFloodlightProvider mockFloodlightProvider = getMockFloodlightProvider();
this.packetIn = this.packetIn.createBuilder()
.setBufferId(OFBufferId.of(10))
.setXid(1)
.build();
OFActionOutput ao = OFFactories.getFactory(OFVersion.OF_13).actions().buildOutput().setPort(OFPort.FLOOD).build();
List<OFAction> al = new ArrayList<OFAction>();
al.add(ao);
// build our expected flooded packetOut
OFPacketOut po = OFFactories.getFactory(OFVersion.OF_13).buildPacketOut()
.setActions(al)
.setXid(1)
.setBufferId(OFBufferId.of(10))
.setInPort(OFPort.of(1))
.build();
// Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
EasyMock.expect(mockSwitch.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
Capture<OFPacketOut> wc1 = new Capture<OFPacketOut>(CaptureType.ALL);
mockSwitch.write(capture(wc1));
// Start recording the replay on the mocks
replay(mockSwitch);
// Get the listener and trigger the packet in
IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
OFType.PACKET_IN).get(0);
listener.receive(mockSwitch, this.packetIn,
parseAndAnnotate(this.packetIn));
// Verify the replay matched our expectations
verify(mockSwitch);
assertTrue(wc1.hasCaptured());
OFMessage m = wc1.getValue();
assertEquals(po, m);
}