use of org.onosproject.openflow.controller.driver.RoleRecvStatus in project onos by opennetworkinglab.
the class RoleManagerTest method deliverRoleReply.
@Test
public void deliverRoleReply() {
RoleRecvStatus status;
RoleReplyInfo asserted = new RoleReplyInfo(MASTER, GID, XID);
RoleReplyInfo unasserted = new RoleReplyInfo(SLAVE, GID, XID);
try {
// call without sendRoleReq() for requestPending = false
// first, sw.role == null
status = manager.deliverRoleReply(asserted);
assertEquals("expectation wrong", OTHER_EXPECTATION, status);
sw.setRole(MASTER);
assertEquals("expectation wrong", OTHER_EXPECTATION, status);
sw.setRole(SLAVE);
// match to pendingRole = MASTER, requestPending = true
manager.sendRoleRequest(MASTER, MATCHED_CURRENT_ROLE);
status = manager.deliverRoleReply(asserted);
assertEquals("expectation wrong", MATCHED_CURRENT_ROLE, status);
// requestPending never gets reset -- this might be a bug.
status = manager.deliverRoleReply(unasserted);
assertEquals("expectation wrong", OTHER_EXPECTATION, status);
assertEquals("pending role mismatch", MASTER, ((TestSwitchDriver) sw).failed);
} catch (IOException | SwitchStateException e) {
assertEquals("unexpected error thrown", SwitchStateException.class, e.getClass());
}
}
Aggregations