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


Java Capture.getValues方法代碼示例

本文整理匯總了Java中org.easymock.Capture.getValues方法的典型用法代碼示例。如果您正苦於以下問題:Java Capture.getValues方法的具體用法?Java Capture.getValues怎麽用?Java Capture.getValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.easymock.Capture的用法示例。


在下文中一共展示了Capture.getValues方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testPollsInBackground

import org.easymock.Capture; //導入方法依賴的package包/類
@Test
public void testPollsInBackground() throws Exception {
    expectInitializeTask();
    expectPollInitialAssignment();

    Capture<Collection<SinkRecord>> capturedRecords = expectPolls(1L);
    expectStopTask();

    PowerMock.replayAll();

    workerTask.initialize(TASK_CONFIG);
    workerTask.initializeAndStart();

    // First iteration initializes partition assignment
    workerTask.iteration();

    // Then we iterate to fetch data
    for (int i = 0; i < 10; i++) {
        workerTask.iteration();
    }
    workerTask.stop();
    workerTask.close();

    // Verify contents match expected values, i.e. that they were translated properly. With max
    // batch size 1 and poll returns 1 message at a time, we should have a matching # of batches
    assertEquals(10, capturedRecords.getValues().size());
    int offset = 0;
    for (Collection<SinkRecord> recs : capturedRecords.getValues()) {
        assertEquals(1, recs.size());
        for (SinkRecord rec : recs) {
            SinkRecord referenceSinkRecord
                    = new SinkRecord(TOPIC, PARTITION, KEY_SCHEMA, KEY, VALUE_SCHEMA, VALUE, FIRST_OFFSET + offset, TIMESTAMP, TIMESTAMP_TYPE);
            assertEquals(referenceSinkRecord, rec);
            offset++;
        }
    }

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:40,代碼來源:WorkerSinkTaskThreadedTest.java

示例2: testSwitchAdded

import org.easymock.Capture; //導入方法依賴的package包/類
@Test
public void testSwitchAdded() throws Exception {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
    linkDiscovery.switchService = getMockSwitchService();
    Capture<OFMessage> wc;
    Set<OFPort> qPorts;
    OFPortDesc ofpp = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc()
    .setName("eth4242")
    .setPortNo(OFPort.of(4242))
    .setHwAddr(MacAddress.of("5c:16:c7:00:00:01"))
    .setCurr(new HashSet<OFPortFeatures>()) // random
    .build();
    IOFSwitch sw1 = createMockSwitch(1L);

    // Set switch map in floodlightProvider.
    Map<DatapathId, IOFSwitch> switches = new HashMap<DatapathId, IOFSwitch>();
    switches.put(DatapathId.of(1L), sw1);
    getMockSwitchService().setSwitches(switches);

    // Create the set of ports
    List<OFPort> ports = new ArrayList<OFPort>();
    for(short p=1; p<=20; ++p) {
        ports.add(OFPort.of(p));
    }

    // Set the captures.
    wc = new Capture<OFMessage>(CaptureType.ALL);

    // Expect switch to return those ports.
    expect(sw1.getEnabledPortNumbers()).andReturn(ports).anyTimes();
    expect(sw1.getPort(OFPort.of(EasyMock.anyInt()))).andReturn(ofpp).anyTimes();
    expect(sw1.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
    expect(sw1.getLatency()).andReturn(U64.ZERO).anyTimes();
    expect(sw1.write(capture(wc))).andReturn(true).anyTimes();
    replay(sw1);

    linkDiscovery.switchActivated(sw1.getId());
    verify(sw1);

    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertFalse(qPorts.isEmpty());

    Thread.sleep(100);
    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertFalse(qPorts.isEmpty());

    Thread.sleep(200);
    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertTrue(qPorts.isEmpty());

    // Ensure that through every switch port, an LLDP and BDDP
    // packet was sent out.  Total # of packets = # of ports * 2.
    assertTrue(wc.hasCaptured());
    List<OFMessage> msgList = wc.getValues();
    assertTrue(msgList.size() == ports.size() * 2);
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:60,代碼來源:LinkDiscoveryManagerTest.java

示例3: testSwitchAdded

import org.easymock.Capture; //導入方法依賴的package包/類
@Test
public void testSwitchAdded() throws Exception {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
    linkDiscovery.switchService = getMockSwitchService();
    Capture<OFMessage> wc;
    Set<OFPort> qPorts;
    OFPortDesc ofpp = OFFactories.getFactory(OFVersion.OF_13).buildPortDesc()
    .setName("eth4242")
    .setPortNo(OFPort.of(4242))
    .setHwAddr(MacAddress.of("5c:16:c7:00:00:01"))
    .setCurr(new HashSet<OFPortFeatures>()) // random
    .build();
    IOFSwitch sw1 = createMockSwitch(1L);

    // Set switch map in floodlightProvider.
    Map<DatapathId, IOFSwitch> switches = new HashMap<DatapathId, IOFSwitch>();
    switches.put(DatapathId.of(1L), sw1);
    getMockSwitchService().setSwitches(switches);

    // Create the set of ports
    List<OFPort> ports = new ArrayList<OFPort>();
    for(short p=1; p<=20; ++p) {
        ports.add(OFPort.of(p));
    }

    // Set the captures.
    wc = new Capture<OFMessage>(CaptureType.ALL);

    // Expect switch to return those ports.
    expect(sw1.getEnabledPortNumbers()).andReturn(ports).anyTimes();
    expect(sw1.getPort(OFPort.of(EasyMock.anyInt()))).andReturn(ofpp).anyTimes();
    expect(sw1.getOFFactory()).andReturn(OFFactories.getFactory(OFVersion.OF_13)).anyTimes();
    sw1.write(capture(wc));
    expectLastCall().anyTimes();
    replay(sw1);

    linkDiscovery.switchActivated(sw1.getId());
    verify(sw1);

    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertFalse(qPorts.isEmpty());

    Thread.sleep(100);
    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertFalse(qPorts.isEmpty());

    Thread.sleep(200);
    qPorts = linkDiscovery.getQuarantinedPorts(sw1.getId());
    assertNotNull(qPorts);
    assertTrue(qPorts.isEmpty());

    // Ensure that through every switch port, an LLDP and BDDP
    // packet was sent out.  Total # of packets = # of ports * 2.
    assertTrue(wc.hasCaptured());
    List<OFMessage> msgList = wc.getValues();
    assertTrue(msgList.size() == ports.size() * 2);
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:60,代碼來源:LinkDiscoveryManagerTest.java


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