use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class ApplicationsWebResource method getAppIds.
/**
* Gets a collection of application ids.
* Returns array of all registered application ids.
*
* @return 200 OK; 404; 401
* @onos.rsModel ApplicationIds
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("ids")
public Response getAppIds() {
CoreService service = get(CoreService.class);
Set<ApplicationId> appIds = service.getAppIds();
return ok(encodeArray(ApplicationId.class, "applicationIds", appIds)).build();
}
use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class ApplicationsResourceTest method setUpMocks.
/**
* Initializes test mocks and environment.
*/
@Before
public void setUpMocks() {
appService = createMock(ApplicationAdminService.class);
coreService = createMock(CoreService.class);
expect(appService.getId("one")).andReturn(id1).anyTimes();
expect(appService.getId("two")).andReturn(id2).anyTimes();
expect(appService.getId("three")).andReturn(id3).anyTimes();
expect(appService.getId("four")).andReturn(id4).anyTimes();
expect(appService.getApplication(id3)).andReturn(app3).anyTimes();
expect(appService.getState(isA(ApplicationId.class))).andReturn(ApplicationState.ACTIVE).anyTimes();
// Register the services needed for the test
CodecManager codecService = new CodecManager();
codecService.activate();
ServiceDirectory testDirectory = new TestServiceDirectory().add(ApplicationAdminService.class, appService).add(ApplicationService.class, appService).add(CoreService.class, coreService).add(CodecService.class, codecService);
setServiceDirectory(testDirectory);
}
use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class XmppControllerImplTest method setUp.
/**
* Sets up devices to use as data, mocks and launches a controller instance.
*/
@Before
public void setUp() {
device1 = new XmppDeviceAdapter();
jid1 = new XmppDeviceId(new JID("agent1@testxmpp.org"));
device2 = new XmppDeviceAdapter();
jid2 = new XmppDeviceId(new JID("agent2@testxmpp.org"));
device3 = new XmppDeviceAdapter();
jid3 = new XmppDeviceId(new JID("agent3@testxmpp.org"));
controller = new XmppControllerImpl();
agent = controller.agent;
testXmppDeviceListener = new TestXmppDeviceListener();
controller.addXmppDeviceListener(testXmppDeviceListener);
testXmppIqListener = new TestXmppIqListener();
controller.addXmppIqListener(testXmppIqListener, testNamespace);
testXmppMessageListener = new TestXmppMessageListener();
controller.addXmppMessageListener(testXmppMessageListener);
testXmppPresenceListener = new TestXmppPresenceListener();
controller.addXmppPresenceListener(testXmppPresenceListener);
CoreService mockCoreService = EasyMock.createMock(CoreService.class);
controller.coreService = mockCoreService;
ComponentConfigService mockCfgService = EasyMock.createMock(ComponentConfigService.class);
expect(mockCfgService.getProperties(anyObject())).andReturn(ImmutableSet.of());
mockCfgService.registerProperties(controller.getClass());
expectLastCall();
mockCfgService.unregisterProperties(controller.getClass(), false);
expectLastCall();
expect(mockCfgService.getProperties(anyObject())).andReturn(ImmutableSet.of());
controller.cfgService = mockCfgService;
replay(mockCfgService);
ComponentContext mockContext = EasyMock.createMock(ComponentContext.class);
Dictionary<String, Object> properties = new Hashtable<>();
properties.put("xmppPort", "5269");
expect(mockContext.getProperties()).andReturn(properties);
replay(mockContext);
controller.activate(mockContext);
}
use of org.onosproject.core.CoreService in project up4 by omec-project.
the class ConfigPscEncap method doExecute.
@Override
protected void doExecute() throws Exception {
if (enable == null) {
return;
}
NetworkConfigService netCfgService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(APP_NAME);
Up4Config config = netCfgService.getConfig(appId, Up4Config.class);
if (config == null) {
print("No UP4 netcfg has been pushed yet");
return;
}
config.setPscEncap(enable);
netCfgService.applyConfig(appId, Up4Config.class, config.node());
}
use of org.onosproject.core.CoreService in project fabric-tna by stratum.
the class FabricIntProgrammableTest method setup.
@Before
public void setup() {
FabricCapabilities capabilities = createMock(FabricCapabilities.class);
expect(capabilities.isArchTna()).andReturn(!this.isArchV1model).anyTimes();
expect(capabilities.isArchV1model()).andReturn(this.isArchV1model).anyTimes();
expect(capabilities.hasHashedTable()).andReturn(true).anyTimes();
expect(capabilities.supportDoubleVlanTerm()).andReturn(false).anyTimes();
expect(capabilities.hwPipeCount()).andReturn(4).anyTimes();
replay(capabilities);
// Services mock
flowRuleService = createMock(FlowRuleService.class);
groupService = createMock(GroupService.class);
netcfgService = createMock(NetworkConfigService.class);
coreService = createMock(CoreService.class);
hostService = createMock(HostService.class);
expect(coreService.getAppId(anyString())).andReturn(APP_ID).anyTimes();
expect(netcfgService.getConfig(LEAF_DEVICE_ID, SegmentRoutingDeviceConfig.class)).andReturn(getSrConfig(LEAF_DEVICE_ID, "/sr.json")).anyTimes();
expect(netcfgService.getConfig(SPINE_DEVICE_ID, SegmentRoutingDeviceConfig.class)).andReturn(getSrConfig(SPINE_DEVICE_ID, "/sr-spine.json")).anyTimes();
expect(hostService.getHostsByIp(COLLECTOR_IP)).andReturn(ImmutableSet.of(COLLECTOR_HOST)).anyTimes();
replay(coreService, netcfgService, hostService);
DriverHandler driverHandler = createMock(DriverHandler.class);
expect(driverHandler.get(FlowRuleService.class)).andReturn(flowRuleService).anyTimes();
expect(driverHandler.get(GroupService.class)).andReturn(groupService).anyTimes();
expect(driverHandler.get(NetworkConfigService.class)).andReturn(netcfgService).anyTimes();
expect(driverHandler.get(CoreService.class)).andReturn(coreService).anyTimes();
expect(driverHandler.get(HostService.class)).andReturn(hostService).anyTimes();
replay(driverHandler);
driverData = createMock(DriverData.class);
expect(driverData.deviceId()).andReturn(LEAF_DEVICE_ID).anyTimes();
replay(driverData);
intProgrammable = partialMockBuilder(FabricIntProgrammable.class).addMockedMethod("getFieldSize").createMock();
expect(intProgrammable.getFieldSize(P4InfoConstants.FABRIC_EGRESS_INT_EGRESS_QUEUE_LATENCY_THRESHOLDS, P4InfoConstants.HDR_HOP_LATENCY_UPPER)).andReturn(16).anyTimes();
expect(intProgrammable.getFieldSize(P4InfoConstants.FABRIC_EGRESS_INT_EGRESS_QUEUE_LATENCY_THRESHOLDS, P4InfoConstants.HDR_HOP_LATENCY_LOWER)).andReturn(16).anyTimes();
replay(intProgrammable);
TestUtils.setField(intProgrammable, "capabilities", capabilities);
TestUtils.setField(intProgrammable, "handler", driverHandler);
TestUtils.setField(intProgrammable, "data", driverData);
TestUtils.setField(intProgrammable, "log", getLogger(""));
testInit();
}
Aggregations