/**
* Test the driver registry: test the bind order
*/
@Test
public void testSwitchDriverRegistryBindOrder() {
IOFSwitchDriver driver1 = createMock(IOFSwitchDriver.class);
IOFSwitchDriver driver2 = createMock(IOFSwitchDriver.class);
IOFSwitchDriver driver3 = createMock(IOFSwitchDriver.class);
IOFSwitch returnedSwitch = null;
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
controller.addOFSwitchDriver("", driver3);
controller.addOFSwitchDriver("test switch", driver1);
controller.addOFSwitchDriver("test", driver2);
replay(driver1);
replay(driver2);
replay(driver3);
replay(mockSwitch);
OFDescriptionStatistics desc = createOFDescriptionStatistics();
desc.setManufacturerDescription("test switch");
desc.setHardwareDescription("version 0.9");
reset(driver1);
reset(driver2);
reset(driver3);
reset(mockSwitch);
mockSwitch.setSwitchProperties(desc);
expectLastCall().once();
expect(driver1.getOFSwitchImpl(desc)).andReturn(mockSwitch).once();
replay(driver1);
replay(driver2);
replay(driver3);
replay(mockSwitch);
returnedSwitch = controller.getOFSwitchInstance(desc);
assertSame(mockSwitch, returnedSwitch);
verify(driver1);
verify(driver2);
verify(driver3);
verify(mockSwitch);
desc = createOFDescriptionStatistics();
desc.setManufacturerDescription("testFooBar");
desc.setHardwareDescription("version 0.9");
reset(driver1);
reset(driver2);
reset(driver3);
reset(mockSwitch);
mockSwitch.setSwitchProperties(desc);
expectLastCall().once();
expect(driver2.getOFSwitchImpl(desc)).andReturn(mockSwitch).once();
replay(driver1);
replay(driver2);
replay(driver3);
replay(mockSwitch);
returnedSwitch = controller.getOFSwitchInstance(desc);
assertSame(mockSwitch, returnedSwitch);
verify(driver1);
verify(driver2);
verify(driver3);
verify(mockSwitch);
desc = createOFDescriptionStatistics();
desc.setManufacturerDescription("FooBar");
desc.setHardwareDescription("version 0.9");
reset(driver1);
reset(driver2);
reset(driver3);
reset(mockSwitch);
mockSwitch.setSwitchProperties(desc);
expectLastCall().once();
expect(driver3.getOFSwitchImpl(desc)).andReturn(mockSwitch).once();
replay(driver1);
replay(driver2);
replay(driver3);
replay(mockSwitch);
returnedSwitch = controller.getOFSwitchInstance(desc);