當前位置: 首頁>>代碼示例>>Java>>正文


Java Capture.getValue方法代碼示例

本文整理匯總了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));
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:20,代碼來源:OFConnectionTest.java

示例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));
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:20,代碼來源:OFConnectionTest.java

示例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));
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:19,代碼來源:OFConnectionTest.java

示例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));
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:20,代碼來源:OFConnectionTest.java

示例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());
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:10,代碼來源:SwitchManagerTest.java

示例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);
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:9,代碼來源:SwitchManagerTest.java

示例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);
}
 
開發者ID:creativechain,項目名稱:creacoinj,代碼行數:9,代碼來源:PaymentChannelServerTest.java

示例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));
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:37,代碼來源:HubTest.java

示例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);
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:41,代碼來源:HubTest.java

示例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));
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:37,代碼來源:HubTest.java

示例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);
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:41,代碼來源:HubTest.java


注:本文中的org.easymock.Capture.getValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。