use of org.onosproject.core.CoreService 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);
}
use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class VirtualNetworkMeterManagerTest method setUp.
@Before
public void setUp() throws Exception {
virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
CoreService coreService = new TestCoreService();
TestStorageService storageService = new TestStorageService();
TestUtils.setField(virtualNetworkManagerStore, "coreService", coreService);
TestUtils.setField(virtualNetworkManagerStore, "storageService", storageService);
virtualNetworkManagerStore.activate();
meterStore = new SimpleVirtualMeterStore();
providerRegistryService = new VirtualProviderManager();
providerRegistryService.registerProvider(provider);
manager = new VirtualNetworkManager();
manager.store = virtualNetworkManagerStore;
TestUtils.setField(manager, "coreService", coreService);
eventDeliveryService = new TestEventDispatcher();
NetTestTools.injectEventDispatcher(manager, eventDeliveryService);
// eventDeliveryService.addSink(VirtualEvent.class, listenerRegistryManager);
appId = new TestApplicationId("MeterManagerTest");
testDirectory = new TestServiceDirectory().add(VirtualNetworkStore.class, virtualNetworkManagerStore).add(CoreService.class, coreService).add(VirtualProviderRegistryService.class, providerRegistryService).add(EventDeliveryService.class, eventDeliveryService).add(StorageService.class, storageService).add(VirtualNetworkMeterStore.class, meterStore);
TestUtils.setField(manager, "serviceDirectory", testDirectory);
manager.activate();
vnet1 = setupVirtualNetworkTopology(manager, TID1);
vnet2 = setupVirtualNetworkTopology(manager, TID2);
meterManager1 = new VirtualNetworkMeterManager(manager, vnet1.id());
meterManager2 = new VirtualNetworkMeterManager(manager, vnet2.id());
providerService1 = (VirtualMeterProviderService) providerRegistryService.getProviderService(vnet1.id(), VirtualMeterProvider.class);
providerService2 = (VirtualMeterProviderService) providerRegistryService.getProviderService(vnet2.id(), VirtualMeterProvider.class);
assertTrue("provider should be registered", providerRegistryService.getProviders().contains(provider.id()));
setupMeterTestVariables();
}
use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class VirtualNetworkPacketManagerTest method setUp.
@Before
public void setUp() throws TestUtils.TestUtilsException {
virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
TestUtils.setField(virtualNetworkManagerStore, "coreService", coreService);
TestUtils.setField(virtualNetworkManagerStore, "storageService", storageService);
virtualNetworkManagerStore.activate();
manager = new VirtualNetworkManager();
manager.store = virtualNetworkManagerStore;
manager.coreService = coreService;
NetTestTools.injectEventDispatcher(manager, new TestEventDispatcher());
flowObjectiveStore = new SimpleVirtualFlowObjectiveStore();
TestUtils.setField(flowObjectiveStore, "storageService", storageService);
flowObjectiveStore.activate();
flowRuleStore = new SimpleVirtualFlowRuleStore();
flowRuleStore.activate();
providerRegistryService = new VirtualProviderManager();
providerRegistryService.registerProvider(provider);
providerRegistryService.registerProvider(flowRuleProvider);
testDirectory = new TestServiceDirectory().add(VirtualNetworkStore.class, virtualNetworkManagerStore).add(CoreService.class, coreService).add(VirtualProviderRegistryService.class, providerRegistryService).add(EventDeliveryService.class, eventDeliveryService).add(ClusterService.class, new ClusterServiceAdapter()).add(VirtualNetworkFlowRuleStore.class, flowRuleStore).add(VirtualNetworkFlowObjectiveStore.class, flowObjectiveStore).add(VirtualNetworkPacketStore.class, packetStore);
TestUtils.setField(manager, "serviceDirectory", testDirectory);
eventDeliveryService = new TestEventDispatcher();
NetTestTools.injectEventDispatcher(manager, eventDeliveryService);
manager.activate();
vnet1 = VirtualNetworkTestUtil.setupVirtualNetworkTopology(manager, TID1);
vnet2 = VirtualNetworkTestUtil.setupVirtualNetworkTopology(manager, TID2);
packetManager1 = new VirtualNetworkPacketManager(manager, vnet1.id());
packetManager2 = new VirtualNetworkPacketManager(manager, vnet2.id());
}
use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class ApplicationsWebResource method getAppIdByName.
/**
* Gets applicationId entry by either id or name.
*
* @param id id of application
* @param name name of application
* @return 200 OK; 404; 401
* @onos.rsModel ApplicationId
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("ids/entry")
public Response getAppIdByName(@QueryParam("id") String id, @QueryParam("name") String name) {
CoreService service = get(CoreService.class);
ApplicationId appId = null;
if (id != null) {
appId = service.getAppId(Short.valueOf(id));
} else if (name != null) {
appId = service.getAppId(name);
}
return response(appId);
}
use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class ApplicationsWebResource method registerAppId.
/**
* Registers an on or off platform application.
*
* @param name application name
* @return 200 OK; 404; 401
* @onos.rsModel ApplicationId
*/
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("{name}/register")
public Response registerAppId(@PathParam("name") String name) {
CoreService service = get(CoreService.class);
ApplicationId appId = service.registerApplication(name);
return response(appId);
}
Aggregations