@Test
public void testSendRoleRequestErrorHandling () throws Exception {

    LinkedList<OFSwitchImpl> switches = new LinkedList<OFSwitchImpl>();
    
    // a switch that supports role requests
    OFSwitchImpl sw1 = EasyMock.createMock(OFSwitchImpl.class);
    // No support for NX_ROLE
    expect(sw1.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE))
                    .andReturn(true); 
    expect(sw1.sendNxRoleRequest(Role.MASTER, 123456))
                .andThrow(new IOException()).once();
    Channel channel1 = createMock(Channel.class);
    expect(sw1.getChannel()).andReturn(channel1);
    expect(channel1.close()).andReturn(null);
    switches.add(sw1);
    
    replay(sw1);
    roleChanger.sendRoleRequest(switches, Role.MASTER, 123456);
    verify(sw1);
    
    assertTrue(switches.isEmpty());
}