use of org.onosproject.net.config.NetworkConfigRegistry in project onos by opennetworkinglab.
the class FibInstallerTest method setUp.
@Before
public void setUp() throws Exception {
sSfibInstaller = new FibInstaller();
sSfibInstaller.componentConfigService = createNiceMock(ComponentConfigService.class);
ComponentContext mockContext = createNiceMock(ComponentContext.class);
routerConfig = new TestRouterConfig();
interfaceService = createMock(InterfaceService.class);
networkConfigService = createMock(NetworkConfigService.class);
networkConfigService.addListener(anyObject(NetworkConfigListener.class));
expectLastCall().anyTimes();
networkConfigRegistry = createMock(NetworkConfigRegistry.class);
flowObjectiveService = createMock(FlowObjectiveService.class);
applicationService = createNiceMock(ApplicationService.class);
replay(applicationService);
deviceService = new TestDeviceService();
CoreService coreService = createNiceMock(CoreService.class);
expect(coreService.registerApplication(anyString())).andReturn(APPID).anyTimes();
replay(coreService);
sSfibInstaller.networkConfigService = networkConfigService;
sSfibInstaller.networkConfigRegistry = networkConfigRegistry;
sSfibInstaller.interfaceService = interfaceService;
sSfibInstaller.flowObjectiveService = flowObjectiveService;
sSfibInstaller.applicationService = applicationService;
sSfibInstaller.coreService = coreService;
sSfibInstaller.routeService = new TestRouteService();
sSfibInstaller.deviceService = deviceService;
setUpNetworkConfigService();
setUpInterfaceService();
sSfibInstaller.activate(mockContext);
}
use of org.onosproject.net.config.NetworkConfigRegistry in project onos by opennetworkinglab.
the class SubjectKeyCompleter method choices.
@Override
protected List<String> choices() {
NetworkConfigRegistry service = AbstractShellCommand.get(NetworkConfigRegistry.class);
String subjectClassKey = commandLine.getArguments()[commandLine.getCursorArgumentIndex() - 1];
SubjectFactory subjectFactory = service.getSubjectFactory(subjectClassKey);
if (subjectFactory == null) {
return Collections.emptyList();
}
// get all registered subject objects.
Set<Object> subjects = service.getSubjects(subjectFactory.subjectClass());
return subjects.stream().map(subjectFactory::subjectKey).collect(Collectors.toList());
}
use of org.onosproject.net.config.NetworkConfigRegistry in project onos by opennetworkinglab.
the class TestCodecService method setup.
@Before
public void setup() throws IOException {
storageService = new TestStorageService();
mastershipService = createNiceMock(MastershipService.class);
coreService = createNiceMock(CoreService.class);
hostService = createNiceMock(HostService.class);
deviceService = createNiceMock(DeviceService.class);
expect(deviceService.getDevices()).andReturn(ImmutableList.of()).anyTimes();
networkConfigRegistry = createNiceMock(NetworkConfigRegistry.class);
networkConfigService = createNiceMock(NetworkConfigService.class);
manager = new SimpleIntManager();
manager.coreService = coreService;
manager.deviceService = deviceService;
manager.storageService = storageService;
manager.mastershipService = mastershipService;
manager.hostService = hostService;
manager.netcfgService = networkConfigService;
manager.netcfgRegistry = networkConfigRegistry;
manager.eventExecutor = MoreExecutors.newDirectExecutorService();
manager.codecService = codecService;
expect(coreService.registerApplication(APP_NAME)).andReturn(APP_ID).anyTimes();
networkConfigRegistry.registerConfigFactory(anyObject());
expectLastCall().once();
Capture<NetworkConfigListener> capture = newCapture();
networkConfigService.addListener(EasyMock.capture(capture));
expectLastCall().once();
IntReportConfig config = getIntReportConfig("/report-config.json");
expect(networkConfigService.getConfig(APP_ID, IntReportConfig.class)).andReturn(config).anyTimes();
replay(mastershipService, deviceService, coreService, hostService, networkConfigRegistry, networkConfigService);
manager.activate();
networkConfigListener = capture.getValue();
}
use of org.onosproject.net.config.NetworkConfigRegistry in project onos by opennetworkinglab.
the class ConfigKeyCompleter method choices.
// FIXME ConfigKeyCompleter never gets called??
@Override
protected List<String> choices() {
NetworkConfigRegistry service = AbstractShellCommand.get(NetworkConfigRegistry.class);
checkArgument(commandLine.getCursorArgumentIndex() >= 2);
String subjectClassKey = commandLine.getArguments()[commandLine.getCursorArgumentIndex() - 2];
SubjectFactory<?> subjectFactory = service.getSubjectFactory(subjectClassKey);
if (subjectFactory == null) {
return ImmutableList.of();
}
String subjectKey = commandLine.getArguments()[commandLine.getCursorArgumentIndex() - 1];
Object subject = subjectFactory.createSubject(subjectKey);
Set<? extends Config<Object>> configs = service.getConfigs(subject);
return configs.stream().map(Config::key).collect(Collectors.toList());
}
use of org.onosproject.net.config.NetworkConfigRegistry 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