本文整理汇总了Java中org.openflow.protocol.OFPortStatus.OFPortReason.values方法的典型用法代码示例。如果您正苦于以下问题:Java OFPortReason.values方法的具体用法?Java OFPortReason.values怎么用?Java OFPortReason.values使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openflow.protocol.OFPortStatus.OFPortReason
的用法示例。
在下文中一共展示了OFPortReason.values方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPortStatusMessageMaster
import org.openflow.protocol.OFPortStatus.OFPortReason; //导入方法依赖的package包/类
/**
* Test port status message handling while MASTER
*
*/
@Test
public void testPortStatusMessageMaster() throws Exception {
long dpid = featuresReply.getDatapathId();
testInitialMoveToMasterWithRole();
OFPhysicalPort p = new OFPhysicalPort();
p.setName("Port1");
p.setPortNumber((short)1);
OFPortStatus ps = (OFPortStatus)
BasicFactory.getInstance().getMessage(OFType.PORT_STATUS);
ps.setDesc(p);
// The events we expect sw.handlePortStatus to return
// We'll just use the same list for all valid OFPortReasons and add
// arbitrary events for arbitrary ports that are not necessarily
// related to the port status message. Our goal
// here is not to return the correct set of events but the make sure
// that a) sw.handlePortStatus is called
// b) the list of events sw.handlePortStatus returns is sent
// as IOFSwitchListener notifications.
OrderedCollection<PortChangeEvent> events =
new LinkedHashSetWrapper<PortChangeEvent>();
ImmutablePort p1 = ImmutablePort.create("eth1", (short)1);
ImmutablePort p2 = ImmutablePort.create("eth2", (short)2);
ImmutablePort p3 = ImmutablePort.create("eth3", (short)3);
ImmutablePort p4 = ImmutablePort.create("eth4", (short)4);
ImmutablePort p5 = ImmutablePort.create("eth5", (short)5);
events.add(new PortChangeEvent(p1, PortChangeType.ADD));
events.add(new PortChangeEvent(p2, PortChangeType.DELETE));
events.add(new PortChangeEvent(p3, PortChangeType.UP));
events.add(new PortChangeEvent(p4, PortChangeType.DOWN));
events.add(new PortChangeEvent(p5, PortChangeType.OTHER_UPDATE));
for (OFPortReason reason: OFPortReason.values()) {
ps.setReason(reason.getReasonCode());
reset(sw);
expect(sw.inputThrottled(anyObject(OFMessage.class)))
.andReturn(false).anyTimes();
expect(sw.getId()).andReturn(dpid).anyTimes();
expect(sw.processOFPortStatus(ps)).andReturn(events).once();
replay(sw);
reset(controller);
controller.notifyPortChanged(sw, p1, PortChangeType.ADD);
controller.notifyPortChanged(sw, p2, PortChangeType.DELETE);
controller.notifyPortChanged(sw, p3, PortChangeType.UP);
controller.notifyPortChanged(sw, p4, PortChangeType.DOWN);
controller.notifyPortChanged(sw, p5, PortChangeType.OTHER_UPDATE);
sendMessageToHandlerNoControllerReset(
Collections.<OFMessage>singletonList(ps));
verify(sw);
verify(controller);
}
}