Search in sources :

Example 6 with OpenflowSwitchDriverAdapter

use of org.onosproject.openflow.OpenflowSwitchDriverAdapter in project onos by opennetworkinglab.

the class OpenFlowControllerImplTest method setUp.

/**
 * Sets up switches to use as data, mocks and launches a controller instance.
 */
@Before
public void setUp() {
    try {
        switch1 = new OpenflowSwitchDriverAdapter();
        dpid1 = Dpid.dpid(new URI("of:0000000000000111"));
        switch2 = new OpenflowSwitchDriverAdapter();
        dpid2 = Dpid.dpid(new URI("of:0000000000000222"));
        switch3 = new OpenflowSwitchDriverAdapter();
        dpid3 = Dpid.dpid(new URI("of:0000000000000333"));
    } catch (URISyntaxException ex) {
        // Does not happen
        fail();
    }
    controller = new OpenFlowControllerImpl();
    agent = controller.agent;
    switchListener = new TestSwitchListener();
    controller.addListener(switchListener);
    CoreService mockCoreService = EasyMock.createMock(CoreService.class);
    controller.coreService = mockCoreService;
    OpenFlowService mockOpenFlowService = EasyMock.createMock(OpenFlowService.class);
    controller.openFlowManager = mockOpenFlowService;
    ComponentConfigService mockConfigService = EasyMock.createMock(ComponentConfigService.class);
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    mockConfigService.registerProperties(controller.getClass());
    expectLastCall();
    mockConfigService.unregisterProperties(controller.getClass(), false);
    expectLastCall();
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    controller.cfgService = mockConfigService;
    replay(mockConfigService);
    NetworkConfigRegistry netConfigService = EasyMock.createMock(NetworkConfigRegistry.class);
    controller.netCfgService = netConfigService;
    ComponentContext mockContext = EasyMock.createMock(ComponentContext.class);
    Dictionary<String, Object> properties = new Hashtable<>();
    properties.put("openflowPorts", Integer.toString(EPHEMERAL_PORT));
    expect(mockContext.getProperties()).andReturn(properties);
    replay(mockContext);
    controller.activate(mockContext);
}
Also used : OpenFlowService(org.onosproject.openflow.controller.OpenFlowService) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) ComponentContext(org.osgi.service.component.ComponentContext) Hashtable(java.util.Hashtable) CoreService(org.onosproject.core.CoreService) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) OpenflowSwitchDriverAdapter(org.onosproject.openflow.OpenflowSwitchDriverAdapter) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) EasyMock.anyObject(org.easymock.EasyMock.anyObject) Before(org.junit.Before)

Aggregations

OpenflowSwitchDriverAdapter (org.onosproject.openflow.OpenflowSwitchDriverAdapter)6 Test (org.junit.Test)4 OFDescStatsReplyAdapter (org.onosproject.openflow.OFDescStatsReplyAdapter)4 OFDescStatsReply (org.projectfloodlight.openflow.protocol.OFDescStatsReply)4 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Before (org.junit.Before)2 MockOfPortStatus (org.onosproject.openflow.MockOfPortStatus)2 Hashtable (java.util.Hashtable)1 EasyMock.anyObject (org.easymock.EasyMock.anyObject)1 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)1 CoreService (org.onosproject.core.CoreService)1 NetworkConfigRegistry (org.onosproject.net.config.NetworkConfigRegistry)1 OpenFlowSwitchListenerAdapter (org.onosproject.openflow.OpenFlowSwitchListenerAdapter)1 OpenFlowService (org.onosproject.openflow.controller.OpenFlowService)1 ComponentContext (org.osgi.service.component.ComponentContext)1