当前位置: 首页>>代码示例>>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;未经允许,请勿转载。