Search in sources :

Example 1 with OpenFlowService

use of org.onosproject.openflow.controller.OpenFlowService 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

URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Hashtable (java.util.Hashtable)1 EasyMock.anyObject (org.easymock.EasyMock.anyObject)1 Before (org.junit.Before)1 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)1 CoreService (org.onosproject.core.CoreService)1 NetworkConfigRegistry (org.onosproject.net.config.NetworkConfigRegistry)1 OpenflowSwitchDriverAdapter (org.onosproject.openflow.OpenflowSwitchDriverAdapter)1 OpenFlowService (org.onosproject.openflow.controller.OpenFlowService)1 ComponentContext (org.osgi.service.component.ComponentContext)1