@Test public void testHandleOutgoingMessage() throws Exception { OFMessage m = factory.buildEchoRequest().build(); IOFSwitchBackend sw = createMock(IOFSwitchBackend.class); expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes(); IOFMessageListener test1 = createMock(IOFMessageListener.class); expect(test1.getName()).andReturn("test1").anyTimes(); setupListenerOrdering(test1); IOFMessageListener test2 = createMock(IOFMessageListener.class); expect(test2.getName()).andReturn("test2").anyTimes(); test2.isCallbackOrderingPostreq(OFType.ECHO_REQUEST, "test1"); expectLastCall().andReturn(true).atLeastOnce(); setupListenerOrdering(test2); IOFMessageListener test3 = createMock(IOFMessageListener.class); expect(test3.getName()).andReturn("test3").anyTimes(); test3.isCallbackOrderingPostreq(OFType.ECHO_REQUEST, "test2"); expectLastCall().andReturn(true).atLeastOnce(); setupListenerOrdering(test3); replay(test1, test2, test3); controller.addOFMessageListener(OFType.ECHO_REQUEST, test1); controller.addOFMessageListener(OFType.ECHO_REQUEST, test3); controller.addOFMessageListener(OFType.ECHO_REQUEST, test2); verify(test1); verify(test2); verify(test3); reset(test1, test2, test3); replay(test1, test2, test3, sw); try { controller.handleOutgoingMessage(null, pi); fail("handleOutgoindMessage should have thrown a NPE"); } catch (NullPointerException e) { } try { controller.handleOutgoingMessage(sw, null); fail("handleOutgoingMessage should have thrown a NPE"); } catch (NullPointerException e) { } verify(test1); verify(test2); verify(test3); verify(sw); reset(test1, test2, test3, sw); expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes(); expect(test2.receive(same(sw), same(m) , isA(FloodlightContext.class))) .andReturn(Command.STOP); expect(test3.receive(same(sw), same(m) , isA(FloodlightContext.class))) .andReturn(Command.CONTINUE); replay(test1, test2, test3, sw); controller.handleOutgoingMessage(sw, m); verify(test1); verify(test2); verify(test3); verify(sw); reset(test1, test2, test3, sw); expect(sw.getId()).andReturn(DATAPATH_ID_0).anyTimes(); expect(test2.receive(same(sw), same(m) , isA(FloodlightContext.class))) .andReturn(Command.STOP); expect(test3.receive(same(sw), same(m) , isA(FloodlightContext.class))) .andReturn(Command.CONTINUE); replay(test1, test2, test3, sw); controller.handleOutgoingMessage(sw, m); verify(test1); verify(test2); verify(test3); verify(sw); reset(test1, test2, test3, sw); replay(test1, test2, test3, sw); m = factory.buildEchoReply().build(); controller.handleOutgoingMessage(sw, m); verify(test1); verify(test2); verify(test3); verify(sw); }
@Override public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) { if (sw == null) throw new NullPointerException("Switch must not be null"); if (m == null) throw new NullPointerException("OFMessage must not be null"); FloodlightContext bc = new FloodlightContext(); List<IOFMessageListener> listeners = null; if (messageListeners.containsKey(m.getType())) { listeners = messageListeners.get(m.getType()).getOrderedListeners(); } if (listeners != null) { for (IOFMessageListener listener : listeners) { if (Command.STOP.equals(listener.receive(sw, m, bc))) { break; } } } }
Controller implements IFloodlightProviderService, IStorageSourceListener, IInfoProvider { @Override public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) { if (sw == null) throw new NullPointerException("Switch must not be null"); if (m == null) throw new NullPointerException("OFMessage must not be null"); FloodlightContext bc = new FloodlightContext(); List<IOFMessageListener> listeners = null; if (messageListeners.containsKey(m.getType())) { listeners = messageListeners.get(m.getType()).getOrderedListeners(); } if (listeners != null) { for (IOFMessageListener listener : listeners) { if (Command.STOP.equals(listener.receive(sw, m, bc))) { break; } } } } }
Controller implements IFloodlightProviderService, IStorageSourceListener, IInfoProvider { @Override public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) { if (sw == null) throw new NullPointerException("Switch must not be null"); if (m == null) throw new NullPointerException("OFMessage must not be null"); FloodlightContext bc = new FloodlightContext(); List<IOFMessageListener> listeners = null; if (messageListeners.containsKey(m.getType())) { listeners = messageListeners.get(m.getType()).getOrderedListeners(); } if (listeners != null) { for (IOFMessageListener listener : listeners) { if (Command.STOP.equals(listener.receive(sw, m, bc))) { break; } } } }  }
Controller implements IFloodlightProviderService, IStorageSourceListener, IInfoProvider { @Override public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) { if (sw == null) throw new NullPointerException("Switch must not be null"); if (m == null) throw new NullPointerException("OFMessage must not be null"); FloodlightContext bc = new FloodlightContext(); List<IOFMessageListener> listeners = null; if (messageListeners.containsKey(m.getType())) { listeners = messageListeners.get(m.getType()).getOrderedListeners(); } if (listeners != null) { for (IOFMessageListener listener : listeners) { if (Command.STOP.equals(listener.receive(sw, m, bc))) { break; } } } }  @Override Set<String> getUplinkPortPrefixSet(); void setUplinkPortPrefixSet(Set<String> prefixSet); @Override ModuleLoaderState getModuleLoaderState(); void setDebugEvent(IDebugEventService debugEvent); void setSwitchService(IOFSwitchService switchService); IOFSwitchService getSwitchService(); @Override int getWorkerThreads(); @Override HARole getRole(); @Override RoleInfo getRoleInfo(); @Override void setRole(HARole role, String changeDescription); @Override void handleMessage(IOFSwitch sw, OFMessage m,
                                 FloodlightContext bContext); @Override String getControllerId(); @Override Set<IPv4Address> getOFAddresses(); @Override TransportPort getOFPort(); @Override synchronized void addCompletionListener(IControllerCompletionListener listener); @Override synchronized void removeCompletionListener(IControllerCompletionListener listener); @Override synchronized void addOFMessageListener(OFType type, IOFMessageListener listener); @Override synchronized void removeOFMessageListener(OFType type, IOFMessageListener listener); void removeOFMessageListeners(OFType type); @Override Map<OFType, List<IOFMessageListener>> getListeners(); @Override void handleOutgoingMessage(IOFSwitch sw, OFMessage m); @Override void run(); void init(Map<String, String> configParams); void startupComponents(FloodlightModuleLoader floodlightModuleLoader); @Override void addInfoProvider(String type, IInfoProvider provider); @Override void removeInfoProvider(String type, IInfoProvider provider); @Override Map<String, Object> getControllerInfo(String type); @Override void addHAListener(IHAListener listener); @Override void removeHAListener(IHAListener listener); @Override Map<String, String> getControllerNodeIPs(); @Override void rowsModified(String tableName, Set<Object> rowKeys); @Override void rowsDeleted(String tableName, Set<Object> rowKeys); @Override long getSystemStartTime(); @Override Map<String, Long> getMemory(); @Override Long getUptime(); @Override void addUpdateToQueue(IUpdate update); @Override Map<String, Object> getInfo(String type); @Override RoleManager getRoleManager(); Optional<ControllerId> getId(); @Override Timer getTimer(); ControllerCounters getCounters(); }
Controller implements IFloodlightProviderService, IStorageSourceListener, IInfoProvider { @Override public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) { if (sw == null) throw new NullPointerException("Switch must not be null"); if (m == null) throw new NullPointerException("OFMessage must not be null"); FloodlightContext bc = new FloodlightContext(); List<IOFMessageListener> listeners = null; if (messageListeners.containsKey(m.getType())) { listeners = messageListeners.get(m.getType()).getOrderedListeners(); } if (listeners != null) { for (IOFMessageListener listener : listeners) { if (Command.STOP.equals(listener.receive(sw, m, bc))) { break; } } } }  @Override Set<String> getUplinkPortPrefixSet(); void setUplinkPortPrefixSet(Set<String> prefixSet); @Override ModuleLoaderState getModuleLoaderState(); void setDebugEvent(IDebugEventService debugEvent); void setSwitchService(IOFSwitchService switchService); IOFSwitchService getSwitchService(); @Override int getWorkerThreads(); @Override HARole getRole(); @Override RoleInfo getRoleInfo(); @Override void setRole(HARole role, String changeDescription); @Override void handleMessage(IOFSwitch sw, OFMessage m,
                                 FloodlightContext bContext); @Override String getControllerId(); @Override Set<IPv4Address> getOFAddresses(); @Override TransportPort getOFPort(); @Override synchronized void addCompletionListener(IControllerCompletionListener listener); @Override synchronized void removeCompletionListener(IControllerCompletionListener listener); @Override synchronized void addOFMessageListener(OFType type, IOFMessageListener listener); @Override synchronized void removeOFMessageListener(OFType type, IOFMessageListener listener); void removeOFMessageListeners(OFType type); @Override Map<OFType, List<IOFMessageListener>> getListeners(); @Override void handleOutgoingMessage(IOFSwitch sw, OFMessage m); @Override void run(); void init(Map<String, String> configParams); void startupComponents(FloodlightModuleLoader floodlightModuleLoader); @Override void addInfoProvider(String type, IInfoProvider provider); @Override void removeInfoProvider(String type, IInfoProvider provider); @Override Map<String, Object> getControllerInfo(String type); @Override void addHAListener(IHAListener listener); @Override void removeHAListener(IHAListener listener); @Override Map<String, String> getControllerNodeIPs(); @Override void rowsModified(String tableName, Set<Object> rowKeys); @Override void rowsDeleted(String tableName, Set<Object> rowKeys); @Override long getSystemStartTime(); @Override Map<String, Long> getMemory(); @Override Long getUptime(); @Override void addUpdateToQueue(IUpdate update); @Override Map<String, Object> getInfo(String type); @Override RoleManager getRoleManager(); Optional<ControllerId> getId(); @Override Timer getTimer(); ControllerCounters getCounters(); static final int SEND_BUFFER_SIZE; }