本文整理汇总了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();
}
示例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);
}
示例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);
}