本文整理汇总了Java中org.openflow.protocol.OFError.setType方法的典型用法代码示例。如果您正苦于以下问题:Java OFError.setType方法的具体用法?Java OFError.setType怎么用?Java OFError.setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openflow.protocol.OFError
的用法示例。
在下文中一共展示了OFError.setType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRoleNotSupportedError
import org.openflow.protocol.OFError; //导入方法依赖的package包/类
@Test
public void testRoleNotSupportedError() throws Exception {
int xid = 424242;
OFChannelState state = new OFChannelState();
state.hsState = HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
chdlr.sw = createMock(OFSwitchImpl.class);
Channel ch = createMock(Channel.class);
// the error returned when role request message is not supported by sw
OFError msg = new OFError();
msg.setType(OFType.ERROR);
msg.setXid(xid);
msg.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
msg.setErrorCode(OFBadRequestCode.OFPBRC_BAD_VENDOR);
// the switch connection should get disconnected when the controller is
// in SLAVE mode and the switch does not support role-request messages
state.firstRoleReplyReceived = false;
controller.role = Role.SLAVE;
expect(chdlr.sw.checkFirstPendingRoleRequestXid(xid)).andReturn(true);
chdlr.sw.deliverRoleRequestNotSupported(xid);
expect(chdlr.sw.getChannel()).andReturn(ch).anyTimes();
expect(ch.close()).andReturn(null);
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertTrue("state.firstRoleReplyReceived must be true",
state.firstRoleReplyReceived);
assertTrue("activeSwitches must be empty",
controller.activeSwitches.isEmpty());
reset(ch, chdlr.sw);
// a different error message - should also reject role request
msg.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
msg.setErrorCode(OFBadRequestCode.OFPBRC_EPERM);
state.firstRoleReplyReceived = false;
controller.role = Role.SLAVE;
expect(chdlr.sw.checkFirstPendingRoleRequestXid(xid)).andReturn(true);
chdlr.sw.deliverRoleRequestNotSupported(xid);
expect(chdlr.sw.getChannel()).andReturn(ch).anyTimes();
expect(ch.close()).andReturn(null);
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertTrue("state.firstRoleReplyReceived must be True even with EPERM",
state.firstRoleReplyReceived);
assertTrue("activeSwitches must be empty",
controller.activeSwitches.isEmpty());
reset(ch, chdlr.sw);
// We are MASTER, the switch should be added to the list of active
// switches.
state.firstRoleReplyReceived = false;
controller.role = Role.MASTER;
expect(chdlr.sw.checkFirstPendingRoleRequestXid(xid)).andReturn(true);
chdlr.sw.deliverRoleRequestNotSupported(xid);
setupSwitchForAddSwitch(chdlr.sw, 0L);
chdlr.sw.clearAllFlowMods();
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertTrue("state.firstRoleReplyReceived must be true",
state.firstRoleReplyReceived);
assertSame("activeSwitches must contain this switch",
chdlr.sw, controller.activeSwitches.get(0L));
reset(ch, chdlr.sw);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:75,代码来源:ControllerTest.java
示例2: testRoleNotSupportedError
import org.openflow.protocol.OFError; //导入方法依赖的package包/类
@Test
public void testRoleNotSupportedError() throws Exception {
int xid = 424242;
OFChannelState state = new OFChannelState();
state.hsState = HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
chdlr.sw = createMock(IOFSwitch.class);
Channel ch = createMock(Channel.class);
// the error returned when role request message is not supported by sw
OFError msg = new OFError();
msg.setType(OFType.ERROR);
msg.setXid(xid);
msg.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
// the switch connection should get disconnected when the controller is
// in SLAVE mode and the switch does not support role-request messages
controller.role = Role.SLAVE;
setupPendingRoleRequest(chdlr.sw, xid, controller.role, 123456);
expect(chdlr.sw.getHARole()).andReturn(null);
chdlr.sw.setHARole(Role.SLAVE, false);
expect(chdlr.sw.getHARole()).andReturn(Role.SLAVE);
chdlr.sw.disconnectOutputStream();
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertTrue("activeSwitches must be empty",
controller.activeSwitches.isEmpty());
reset(ch, chdlr.sw);
// We are MASTER, the switch should be added to the list of active
// switches.
controller.role = Role.MASTER;
setupPendingRoleRequest(chdlr.sw, xid, controller.role, 123456);
expect(chdlr.sw.getHARole()).andReturn(null);
chdlr.sw.setHARole(controller.role, false);
setupSwitchForAddSwitch(chdlr.sw, 0L);
chdlr.sw.clearAllFlowMods();
expect(chdlr.sw.getHARole()).andReturn(null).anyTimes();
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertSame("activeSwitches must contain this switch",
chdlr.sw, controller.activeSwitches.get(0L));
reset(ch, chdlr.sw);
}
示例3: testRoleNotSupportedError
import org.openflow.protocol.OFError; //导入方法依赖的package包/类
@Test
public void testRoleNotSupportedError() throws Exception {
int xid = 424242;
OFChannelState state = new OFChannelState();
state.hsState = HandshakeState.READY;
Controller.OFChannelHandler chdlr = controller.new OFChannelHandler(state);
chdlr.sw = createMock(IOFSwitch.class);
Channel ch = createMock(Channel.class);
// the error returned when role request message is not supported by sw
OFError msg = new OFError();
msg.setType(OFType.ERROR);
msg.setXid(xid);
msg.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
// the switch connection should get disconnected when the controller is
// in SLAVE mode and the switch does not support role-request messages
controller.role = Role.SLAVE;
setupPendingRoleRequest(chdlr.sw, xid, controller.role, 123456);
expect(chdlr.sw.getHARole()).andReturn(null);
chdlr.sw.setHARole(Role.SLAVE, false);
expect(chdlr.sw.getHARole()).andReturn(Role.SLAVE);
chdlr.sw.disconnectOutputStream();
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertTrue("activeSwitches must be empty",
controller.activeSwitches.isEmpty());
reset(ch, chdlr.sw);
// We are MASTER, the switch should be added to the list of active
// switches.
controller.role = Role.MASTER;
setupPendingRoleRequest(chdlr.sw, xid, controller.role, 123456);
expect(chdlr.sw.getHARole()).andReturn(null);
chdlr.sw.setHARole(controller.role, false);
setupSwitchForAddSwitch(chdlr.sw, 0L);
chdlr.sw.clearAllFlowMods();
expect(chdlr.sw.getHARole()).andReturn(null).anyTimes();
replay(ch, chdlr.sw);
chdlr.processOFMessage(msg);
verify(ch, chdlr.sw);
assertSame("activeSwitches must contain this switch",
chdlr.sw, controller.activeSwitches.get(0L));
reset(ch, chdlr.sw);
}