当前位置: 首页>>代码示例>>Java>>正文


Java OFPortReason.values方法代码示例

本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFPortReason.values方法的典型用法代码示例。如果您正苦于以下问题:Java OFPortReason.values方法的具体用法?Java OFPortReason.values怎么用?Java OFPortReason.values使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.projectfloodlight.openflow.protocol.OFPortReason的用法示例。


在下文中一共展示了OFPortReason.values方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPortStatusMessageMaster

import org.projectfloodlight.openflow.protocol.OFPortReason; //导入方法依赖的package包/类
/**
 * Test port status message handling while MASTER
 *
 */
@Test
public void testPortStatusMessageMaster() throws Exception {
	DatapathId dpid = featuresReply.getDatapathId();
	testInitialMoveToMasterWithRole();

	OFPortDesc portDesc = factory.buildPortDesc()
			.setName("Port1")
			.setPortNo(OFPort.of(1))
			.build();
	OFPortStatus.Builder portStatusBuilder = factory.buildPortStatus()
			.setDesc(portDesc);

	// 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>();
	OFPortDesc.Builder pb = factory.buildPortDesc();
	OFPortDesc p1 = pb.setName("eth1").setPortNo(OFPort.of(1)).build();
	OFPortDesc p2 = pb.setName("eth2").setPortNo(OFPort.of(2)).build();
	OFPortDesc p3 = pb.setName("eth3").setPortNo(OFPort.of(3)).build();
	OFPortDesc p4 = pb.setName("eth4").setPortNo(OFPort.of(4)).build();
	OFPortDesc p5 = pb.setName("eth5").setPortNo(OFPort.of(5)).build();


	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()) {
		OFPortStatus portStatus = portStatusBuilder.setReason(reason).build();

		reset(sw);
		expect(sw.getId()).andReturn(dpid).anyTimes();

		expect(sw.processOFPortStatus(portStatus)).andReturn(events).once();
		replay(sw);

		reset(switchManager);
		switchManager.notifyPortChanged(sw, p1, PortChangeType.ADD);
		switchManager.notifyPortChanged(sw, p2, PortChangeType.DELETE);
		switchManager.notifyPortChanged(sw, p3, PortChangeType.UP);
		switchManager.notifyPortChanged(sw, p4, PortChangeType.DOWN);
		switchManager.notifyPortChanged(sw, p5, PortChangeType.OTHER_UPDATE);
		replay(switchManager);

		switchHandler.processOFMessage(portStatus);

		verify(sw);
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:64,代码来源:OFSwitchHandlerTestBase.java

示例2: testPortStatusMessageMaster

import org.projectfloodlight.openflow.protocol.OFPortReason; //导入方法依赖的package包/类
/**
 * Test port status message handling while MASTER
 *
 */
@Test
public void testPortStatusMessageMaster() throws Exception {
    DatapathId dpid = featuresReply.getDatapathId();
    testInitialMoveToMasterWithRole();

    OFPortDesc portDesc = factory.buildPortDesc()
            .setName("Port1")
            .setPortNo(OFPort.of(1))
            .build();
    OFPortStatus.Builder portStatusBuilder = factory.buildPortStatus()
            .setDesc(portDesc);

    // 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>();
    OFPortDesc.Builder pb = factory.buildPortDesc();
    OFPortDesc p1 = pb.setName("eth1").setPortNo(OFPort.of(1)).build();
    OFPortDesc p2 = pb.setName("eth2").setPortNo(OFPort.of(2)).build();
    OFPortDesc p3 = pb.setName("eth3").setPortNo(OFPort.of(3)).build();
    OFPortDesc p4 = pb.setName("eth4").setPortNo(OFPort.of(4)).build();
    OFPortDesc p5 = pb.setName("eth5").setPortNo(OFPort.of(5)).build();

    
    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()) {
        OFPortStatus portStatus = portStatusBuilder.setReason(reason).build();

        reset(sw);
        expect(sw.getId()).andReturn(dpid).anyTimes();

        expect(sw.processOFPortStatus(portStatus)).andReturn(events).once();
        replay(sw);

        reset(switchManager);
        switchManager.notifyPortChanged(sw, p1, PortChangeType.ADD);
        switchManager.notifyPortChanged(sw, p2, PortChangeType.DELETE);
        switchManager.notifyPortChanged(sw, p3, PortChangeType.UP);
        switchManager.notifyPortChanged(sw, p4, PortChangeType.DOWN);
        switchManager.notifyPortChanged(sw, p5, PortChangeType.OTHER_UPDATE);
        replay(switchManager);

        switchHandler.processOFMessage(portStatus);

        verify(sw);
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:64,代码来源:OFSwitchHandlerTestBase.java


注:本文中的org.projectfloodlight.openflow.protocol.OFPortReason.values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。