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);
}
Aggregations