protected void setupPendingRoleRequest(IOFSwitch sw, int xid, Role role, long cookie) { LinkedList<PendingRoleRequestEntry> pendingList = new LinkedList<PendingRoleRequestEntry>(); controller.roleChanger.pendingRequestMap.put(sw, pendingList); PendingRoleRequestEntry entry = new PendingRoleRequestEntry(xid, role, cookie); pendingList.add(entry); }
@Test public void testVerifyRoleReplyReceived() throws Exception { Collection<IOFSwitch> switches = new LinkedList<IOFSwitch>(); // Add a switch that has received a role reply IOFSwitch sw1 = EasyMock.createMock(IOFSwitch.class); LinkedList<PendingRoleRequestEntry> pendingList1 = new LinkedList<PendingRoleRequestEntry>(); roleChanger.pendingRequestMap.put(sw1, pendingList1); switches.add(sw1); // Add a switch that has not yet received a role reply IOFSwitch sw2 = EasyMock.createMock(IOFSwitch.class); LinkedList<PendingRoleRequestEntry> pendingList2 = new LinkedList<PendingRoleRequestEntry>(); roleChanger.pendingRequestMap.put(sw2, pendingList2); PendingRoleRequestEntry entry = new PendingRoleRequestEntry(1, Role.MASTER, 123456); pendingList2.add(entry); // Timed out switch should become active expect(sw2.getAttribute(IOFSwitch.SWITCH_DESCRIPTION_DATA)) .andReturn(null); expect(sw2.getHARole()).andReturn(null); sw2.setHARole(Role.MASTER, false); EasyMock.expectLastCall(); switches.add(sw2); replay(sw1, sw2); roleChanger.verifyRoleReplyReceived(switches, 123456); verify(sw1, sw2); assertEquals(2, switches.size()); }
protected void setupPendingRoleRequest(IOFSwitch sw, int xid, Role role, long cookie) { LinkedList<PendingRoleRequestEntry> pendingList = new LinkedList<PendingRoleRequestEntry>(); roleChanger.pendingRequestMap.put(sw, pendingList); PendingRoleRequestEntry entry = new PendingRoleRequestEntry(xid, role, cookie); pendingList.add(entry); }