Java 类net.floodlightcontroller.core.IOFSwitchListener 实例源码
项目:fresco_floodlight
文件:OFSwitchManagerTest.java
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
expect(sw.getOFFactory()).andReturn(factory).once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:fresco_floodlight
文件:OFSwitchManagerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
// create a new mock switch
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
replay(sw, listener);
switchManager.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
replay(origSw);
assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
项目:iTAP-controller
文件:OFSwitchManagerTest.java
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:iTAP-controller
文件:OFSwitchManagerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
// create a new mock switch
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
replay(sw, listener);
switchManager.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
replay(origSw);
assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
项目:SDN-Multicast
文件:OFSwitchManagerTest.java
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
expect(sw.getOFFactory()).andReturn(factory).once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:SDN-Multicast
文件:OFSwitchManagerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
// create a new mock switch
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
replay(sw, listener);
switchManager.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
replay(origSw);
assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
项目:arscheduler
文件:OFSwitchManagerTest.java
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
expect(sw.getOFFactory()).andReturn(factory).once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:arscheduler
文件:OFSwitchManagerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
// create a new mock switch
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
replay(sw, listener);
switchManager.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
replay(origSw);
assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
项目:QoS-floodlight
文件:ControllerTest.java
/**
* Disconnect a switch. normal program flow
*/
@Test
private void doTestSwitchConnectReconnect(boolean reconnect)
throws Exception {
IOFSwitch sw = doActivateNewSwitch(1L, null, null);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
sw.cancelAllStatisticsReplies();
expectLastCall().once();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
listener.switchRemoved(1L);
expectLastCall().once();
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertNull(controller.getSwitch(1L));
assertNull(storeClient.getValue(1L));
if (reconnect) {
controller.removeOFSwitchListener(listener);
sw = doActivateOldSwitch(1L, null, null);
}
}
项目:QoS-floodlight
文件:ControllerTest.java
/**
* Remove a nonexisting switch. should be ignored
*/
@Test
public void testNonexistingSwitchDisconnected() throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertNull(controller.getSwitch(1L));
assertNull(storeClient.getValue(1L));
}
项目:QoS-floodlight
文件:ControllerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(1L, null, null);
// create a new mock switch
IOFSwitch sw = createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertSame(origSw, controller.getSwitch(1L));
assertNotNull(storeClient.getValue(1L));
}
项目:floodlight1.2-delay
文件:OFSwitchManagerTest.java
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
expect(sw.getOFFactory()).andReturn(factory).once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:floodlight1.2-delay
文件:OFSwitchManagerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
// create a new mock switch
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
replay(sw, listener);
switchManager.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
replay(origSw);
assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
项目:floodlight-hardware
文件:OFSwitchManagerTest.java
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
expect(sw.getOFFactory()).andReturn(factory).once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:floodlight-hardware
文件:OFSwitchManagerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
// create a new mock switch
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
replay(sw, listener);
switchManager.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
replay(origSw);
assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
项目:ACAMPController
文件:OFSwitchManagerTest.java
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
expect(sw.getOFFactory()).andReturn(factory).once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:ACAMPController
文件:OFSwitchManagerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
// create a new mock switch
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
replay(sw, listener);
switchManager.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
replay(origSw);
assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
项目:fast-failover-demo
文件:OFSwitchManagerTest.java
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
expect(sw.getOFFactory()).andReturn(factory).once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:fast-failover-demo
文件:OFSwitchManagerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
// create a new mock switch
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
replay(sw, listener);
switchManager.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
replay(origSw);
assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
项目:floodlightLB
文件:OFSwitchManagerTest.java
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
expect(sw.getOFFactory()).andReturn(factory).once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:floodlightLB
文件:OFSwitchManagerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
// create a new mock switch
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
replay(sw, listener);
switchManager.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
replay(origSw);
assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
项目:DSC
文件:OFSwitchManagerTest.java
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:DSC
文件:OFSwitchManagerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
// create a new mock switch
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
replay(sw, listener);
switchManager.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
replay(origSw);
assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
项目:floodlight_with_topoguard
文件:ControllerTest.java
/**
* Disconnect a switch. normal program flow
*/
@Test
private void doTestSwitchConnectReconnect(boolean reconnect)
throws Exception {
IOFSwitch sw = doActivateNewSwitch(1L, null, null);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
sw.cancelAllStatisticsReplies();
expectLastCall().once();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
listener.switchRemoved(1L);
expectLastCall().once();
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertNull(controller.getSwitch(1L));
assertNull(storeClient.getValue(1L));
if (reconnect) {
controller.removeOFSwitchListener(listener);
sw = doActivateOldSwitch(1L, null, null);
}
}
项目:floodlight_with_topoguard
文件:ControllerTest.java
/**
* Remove a nonexisting switch. should be ignored
*/
@Test
public void testNonexistingSwitchDisconnected() throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertNull(controller.getSwitch(1L));
assertNull(storeClient.getValue(1L));
}
项目:floodlight_with_topoguard
文件:ControllerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(1L, null, null);
// create a new mock switch
IOFSwitch sw = createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertSame(origSw, controller.getSwitch(1L));
assertNotNull(storeClient.getValue(1L));
}
项目:floodlight
文件:OFSwitchManagerTest.java
/**
* Test switchActivated for a new switch while in slave: disconnect the switch
*/
@Test
public void testNewSwitchActivatedWhileSlave() throws Exception {
doSetUp(HARole.STANDBY);
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes();
expect(sw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
sw.disconnect();
expectLastCall().once();
replay(sw, listener); // nothing recorded
switchManager.switchAdded(sw);
switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.MASTER);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:floodlight
文件:OFSwitchManagerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(DATAPATH_ID_1, null, null);
// create a new mock switch
IOFSwitchBackend sw = createMock(IOFSwitchBackend.class);
expect(sw.getId()).andReturn(DATAPATH_ID_1).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
switchManager.addOFSwitchListener(listener);
replay(sw, listener);
switchManager.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
expect(origSw.getStatus()).andReturn(SwitchStatus.MASTER).anyTimes();
replay(origSw);
assertSame(origSw, switchManager.getSwitch(DATAPATH_ID_1));
}
项目:FloodligtModule
文件:ControllerTest.java
/**
* Disconnect a switch. normal program flow
*/
@Test
private void doTestSwitchConnectReconnect(boolean reconnect)
throws Exception {
IOFSwitch sw = doActivateNewSwitch(1L, null, null);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
sw.cancelAllStatisticsReplies();
expectLastCall().once();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
listener.switchRemoved(1L);
expectLastCall().once();
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertNull(controller.getSwitch(1L));
assertNull(storeClient.getValue(1L));
if (reconnect) {
controller.removeOFSwitchListener(listener);
sw = doActivateOldSwitch(1L, null, null);
}
}
项目:FloodligtModule
文件:ControllerTest.java
/**
* Remove a nonexisting switch. should be ignored
*/
@Test
public void testNonexistingSwitchDisconnected() throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertNull(controller.getSwitch(1L));
assertNull(storeClient.getValue(1L));
}
项目:FloodligtModule
文件:ControllerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(1L, null, null);
// create a new mock switch
IOFSwitch sw = createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertSame(origSw, controller.getSwitch(1L));
assertNotNull(storeClient.getValue(1L));
}
项目:smartenit
文件:Controller.java
public void dispatch() {
if (log.isTraceEnabled()) {
log.trace("Dispatching switch update {} {}",
sw, switchUpdateType);
}
if (switchListeners != null) {
for (IOFSwitchListener listener : switchListeners) {
switch(switchUpdateType) {
case ADDED:
listener.addedSwitch(sw);
break;
case REMOVED:
listener.removedSwitch(sw);
break;
case PORTCHANGED:
listener.switchPortChanged(sw.getId());
break;
}
}
}
}
项目:smartenit
文件:Controller.java
/**
* Initialize internal data structures
*/
public void init(Map<String, String> configParams) {
// These data structures are initialized here because other
// module's startUp() might be called before ours
this.messageListeners =
new ConcurrentHashMap<OFType,
ListenerDispatcher<OFType,
IOFMessageListener>>();
this.switchListeners = new CopyOnWriteArraySet<IOFSwitchListener>();
this.haListeners = new CopyOnWriteArraySet<IHAListener>();
this.activeSwitches = new ConcurrentHashMap<Long, IOFSwitch>();
this.connectedSwitches = new HashSet<OFSwitchImpl>();
this.controllerNodeIPsCache = new HashMap<String, String>();
this.updates = new LinkedBlockingQueue<IUpdate>();
this.factory = new BasicFactory();
this.providerMap = new HashMap<String, List<IInfoProvider>>();
setConfigParams(configParams);
this.role = getInitialRole(configParams);
this.roleChanger = new RoleChanger();
initVendorMessages();
this.systemStartTime = System.currentTimeMillis();
}
项目:multicastSDN
文件:ControllerTest.java
/**
* Disconnect a switch. normal program flow
*/
@Test
private void doTestSwitchConnectReconnect(boolean reconnect)
throws Exception {
IOFSwitch sw = doActivateNewSwitch(1L, null, null);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
sw.cancelAllStatisticsReplies();
expectLastCall().once();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
listener.switchRemoved(1L);
expectLastCall().once();
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertNull(controller.getSwitch(1L));
assertNull(storeClient.getValue(1L));
if (reconnect) {
controller.removeOFSwitchListener(listener);
sw = doActivateOldSwitch(1L, null, null);
}
}
项目:multicastSDN
文件:ControllerTest.java
/**
* Remove a nonexisting switch. should be ignored
*/
@Test
public void testNonexistingSwitchDisconnected() throws Exception {
IOFSwitch sw = createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertNull(controller.getSwitch(1L));
assertNull(storeClient.getValue(1L));
}
项目:multicastSDN
文件:ControllerTest.java
/**
* Try to remove a switch that's different from what's in the active
* switch map. Should be ignored
*/
@Test
public void testSwitchDisconnectedOther() throws Exception {
IOFSwitch origSw = doActivateNewSwitch(1L, null, null);
// create a new mock switch
IOFSwitch sw = createMock(IOFSwitch.class);
expect(sw.getId()).andReturn(1L).anyTimes();
expect(sw.getStringId()).andReturn(HexString.toHexString(1L)).anyTimes();
IOFSwitchListener listener = createMock(IOFSwitchListener.class);
controller.addOFSwitchListener(listener);
replay(sw, listener);
controller.switchDisconnected(sw);
controller.processUpdateQueueForTesting();
verify(sw, listener);
assertSame(origSw, controller.getSwitch(1L));
assertNotNull(storeClient.getValue(1L));
}
项目:spring-open
文件:ControllerTest.java
/**
* Test adding a new switch in the MASTER role.
* We expect a switchActivatedMaster event fired to the switch listeners.
*/
@Test
public void testSwitchActivatedMaster() throws Exception {
long dpid = 1L;
controller.setAlwaysClearFlowsOnSwActivate(false);
controller.setAlwaysClearFlowsOnSwAdd(false);
// Create a 1.0 switch. There's no difference between 1.0 and 1.3 here.
IOFSwitch sw = createMockSwitch(dpid, OFVersion.OF_10);
// strict mock. Order of events matters!
IOFSwitchListener listener = createStrictMock(IOFSwitchListener.class);
listener.switchActivatedMaster(dpid);
expectLastCall().once();
replay(listener);
controller.addOFSwitchListener(listener);
replay(sw);
controller.addConnectedSwitch(dpid, new OFChannelHandler(controller));
controller.addActivatedMasterSwitch(dpid, sw);
verify(sw);
assertEquals(sw, controller.getMasterSwitch(dpid));
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:spring-open
文件:ControllerTest.java
/**
* Test adding a new switch in the EQUAL role.
* We expect a switchActivatedEqual event fired to the switch listeners.
*/
@Test
public void testSwitchActivatedEqual() throws Exception {
long dpid = 1L;
// Create a 1.0 switch. There's no difference between 1.0 and 1.3 here.
IOFSwitch sw = createMockSwitch(dpid, OFVersion.OF_10);
IOFSwitchListener listener = createStrictMock(IOFSwitchListener.class);
controller.addOFSwitchListener(listener);
listener.switchActivatedEqual(dpid);
replay(sw, listener); // nothing recorded
controller.addConnectedSwitch(dpid, new OFChannelHandler(controller));
controller.addActivatedEqualSwitch(dpid, sw);
verify(sw);
controller.processUpdateQueueForTesting();
verify(listener);
}
项目:floodlight-qosmanager
文件:Controller.java
public void dispatch() {
if (log.isTraceEnabled()) {
log.trace("Dispatching switch update {} {}",
sw, switchUpdateType);
}
if (switchListeners != null) {
for (IOFSwitchListener listener : switchListeners) {
switch(switchUpdateType) {
case ADDED:
listener.addedSwitch(sw);
break;
case REMOVED:
listener.removedSwitch(sw);
break;
case PORTCHANGED:
listener.switchPortChanged(sw.getId());
break;
}
}
}
}
项目:floodlight-qosmanager
文件:Controller.java
/**
* Initialize internal data structures
*/
public void init(Map<String, String> configParams) {
// These data structures are initialized here because other
// module's startUp() might be called before ours
this.messageListeners =
new ConcurrentHashMap<OFType,
ListenerDispatcher<OFType,
IOFMessageListener>>();
this.switchListeners = new CopyOnWriteArraySet<IOFSwitchListener>();
this.haListeners = new CopyOnWriteArraySet<IHAListener>();
this.activeSwitches = new ConcurrentHashMap<Long, IOFSwitch>();
this.connectedSwitches = new HashSet<OFSwitchImpl>();
this.controllerNodeIPsCache = new HashMap<String, String>();
this.updates = new LinkedBlockingQueue<IUpdate>();
this.factory = new BasicFactory();
this.providerMap = new HashMap<String, List<IInfoProvider>>();
setConfigParams(configParams);
this.role = getInitialRole(configParams);
this.roleChanger = new RoleChanger();
initVendorMessages();
this.systemStartTime = System.currentTimeMillis();
}